-
Notifications
You must be signed in to change notification settings - Fork 254
Add NrrdWriter for multi-channel arrays #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
* Draft Training workflow for NuClick Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * Sync up changes for nuclick training Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * Fix nuclick training Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * rename transform Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * Sync up changes for nuclick training Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * use monai bunet for nuclick Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> * fix log Signed-off-by: Sachidanand Alle <sachidanand.alle@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com> Co-authored-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com> Co-authored-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
write_seg_nrrd() is only needed for 4D multi-channel label arrays. Everything else can be handled by ITK of nifty writer. Signed-off-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Janis Vahldiek <janis@vahldiek.info> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
dfc2011 to
4cf50dd
Compare
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
|
Thanks for raising the PR.. will be look into this asap.. |
| def write_seg_nrrd( | ||
| image_np: np.ndarray, | ||
| output_file: str, | ||
| dtype: type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be u can have default value for dtype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tried to make this function's signature similar to the write_itk(). It is probably best to also have a default there as well then, would you agree?
monailabel/transform/writer.py
Outdated
|
|
||
| if self.is_multichannel_image(image_np): | ||
| if ext != ".seg.nrrd": | ||
| logger.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be logger info or warning
monailabel/transform/writer.py
Outdated
| return output_file, output_json | ||
|
|
||
| def is_multichannel_image(self, image_np): | ||
| return len(image_np.shape) == 4 and image_np.shape[-1] > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channel last? normally all images/labels/predictions are processed as channel first in post transform... we better cross check by running some examples e2e..
@diazandr3s can u help to verify this feature...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to help :)
Should we wait until this PR (Project-MONAI/MONAI#4259) is merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can checkout the remote branch and verify..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Project-MONAI/MONAI#4259 is merged now. I merged upstream/main into this branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this seemed wrong, I updated the code to check the first dimension instead.
FYI:
pynrrd choses the following convention
default index_order='F'
nrrd.writer.write(data)
index_order : {'C', 'F'}, optional
Specifies the index order used for writing. Either
'C' (C-order)
where the dimensions are ordered from
slowest-varying to fastest-varying (e.g. (z, y, x)),
'F' (Fortran-order)
where the dimensions are ordered
from fastest-varying to slowest-varying (e.g. (x, y, z)).
We chose 'C' as a default here
torch has the following convention: NxCxHxW
At the moment, in our monailabel-app, we use (5, 4280, 3520, 1) = (channels, width, height, batch)
Thanks, @markus-hinsche CC @lassoan |
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
* Add Active Learning strategies to DeepEdit Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> * Update readme - commands Active Learning strategies Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
…I#781) * Prepare MONAI Label for new monai - DeepEdit transforms Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> * Add deprecated messages - DeepEdit transforms - interaction Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> Co-authored-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
* Add original labels option Slicer UI Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> * Update Slicer module Signed-off-by: Andres Diaz-Pinto <diazandr3s@gmail.com> Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
26d96f9 to
2606586
Compare
|
can you please fix the base branch.. it complains out-of-date and can't be done through UI |
I am not sure what the problem is. Feel free to elaborate |
diazandr3s
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Looks good to me.
|
Great! Thanks for the feedback |
|
Can't merge as it says out of date |
Signed-off-by: Markus Hinsche <m.hinsche@gmail.com>
|
I see the problem.. u have forked the forked repo.. can you please fix the fork and resolve the conflicts correct.. if possible i suggest please fork from the original repo.. |
|
Closing in favor of #793 |
Motivation
The
Writerclass (inmonailabel/transform/writer.py) can't handle multi-channel arrays. The ITK reader and writer both can't handle multi-channel arrays, therefore we want to introduce a new writer that can do this.Related PRs
This work is related to other works in this area:
NrrdReaderfornrrdandseg.nrrdfiles MONAI#4238 with PR Implement NrrdReader MONAI#4259seg.nrrdtooling with 3D SlicerChanges
write_seg_nrrd()(similar towrite_itk())pynrrdpip dependency to project