Add NrrdWriter for multi-channel arrays#779
Add NrrdWriter for multi-channel arrays#779markus-hinsche wants to merge 26 commits intoProject-MONAI:mainfrom
Conversation
Signed-off-by: Sachidanand Alle <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
* Draft Training workflow for NuClick Signed-off-by: Sachidanand Alle <[email protected]> * Sync up changes for nuclick training Signed-off-by: Sachidanand Alle <[email protected]> * Fix nuclick training Signed-off-by: Sachidanand Alle <[email protected]> * rename transform Signed-off-by: Sachidanand Alle <[email protected]> * Sync up changes for nuclick training Signed-off-by: Sachidanand Alle <[email protected]> * use monai bunet for nuclick Signed-off-by: Sachidanand Alle <[email protected]> * fix log Signed-off-by: Sachidanand Alle <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]> Co-authored-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]> Co-authored-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
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 <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
write_seg_nrrd() will only be used for 4D multi-channel label arrays. Thus, removed unnecessary code. Signed-off-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Janis Vahldiek <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
dfc2011 to
4cf50dd
Compare
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
|
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.
may be u can have default value for dtype
There was a problem hiding this comment.
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.
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.
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.
Happy to help :)
Should we wait until this PR (Project-MONAI/MONAI#4259) is merged?
There was a problem hiding this comment.
you can checkout the remote branch and verify..
There was a problem hiding this comment.
Project-MONAI/MONAI#4259 is merged now. I merged upstream/main into this branch
There was a problem hiding this comment.
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 <[email protected]>
* Add Active Learning strategies to DeepEdit Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update readme - commands Active Learning strategies Signed-off-by: Andres Diaz-Pinto <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
…I#781) * Prepare MONAI Label for new monai - DeepEdit transforms Signed-off-by: Andres Diaz-Pinto <[email protected]> * Add deprecated messages - DeepEdit transforms - interaction Signed-off-by: Andres Diaz-Pinto <[email protected]> Co-authored-by: SACHIDANAND ALLE <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: SACHIDANAND ALLE <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
* Add original labels option Slicer UI Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update Slicer module Signed-off-by: Andres Diaz-Pinto <[email protected]> Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
Signed-off-by: Markus Hinsche <[email protected]>
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.
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 <[email protected]>
|
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