-
Notifications
You must be signed in to change notification settings - Fork 52
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
Write NRRD file with header 'space origin' has format bug #82
Comments
Is there a reason you need to call
The So you should be able to do this:
|
No particular reason for calling |
Okay, I understand. As far as I can tell, this is probably not an issue with the If you want to experiment, open the NRRD file in your notepad editor and manually add a My first guess as to why it won't display in 3D Slicer is that 3D Slicer is not not centering the camera over the object for some reason. When the origin is missing, I assume it defaults to (0, 0, 0) and then 3D Slicer displays the camera there. |
See here for some background: https://www.slicer.org/wiki/Coordinate_systems @gliu2 if you need to DICOM->NRRD conversion, you will probably save a lot time using dcm2niix -- which now has both Nifti and NRRD output (both supported by Slicer), or one of Slicer's built-in importers. At very least those converters will give you a good baseline to compare to. If you are writing NRRDs from scratch (e.g. for simulation output or something), and you get stuck, I suggest posting on https://discourse.slicer.org for help with making a NRRD that Slicer will interpret correctly. Addison's suggestion to manually edit is spot-on. |
Writing an NRRD with the 'space origin' header key (to specify spatial translation of CT scan) requires an input of type NRRD vector for the CT origin. However using the function
nrrd.format_optional_vector
creates a vector as a string (e.g. '(3,4,1)') which triggers the following error when writing an NRRD file:This is the code I am running:
nrrd.write(os.path.join(foldername, filename), M_out, detached_header=False, header={'sizes': size_image, 'spacings': spacing, 'space origin':nrrd.format_optional_vector(origin)})
I believe this bug can be corrected by changing line 81 of formatters.py from:
if x is None or np.all(np.isnan(x)):
to:
if x is None or np.all(pd.isnull(x)):
after adding an 'import panda as pd' line to beginning of code.
Thanks
The text was updated successfully, but these errors were encountered: