Closed nicholsn closed 11 years ago
Thanks for working on this!
I have made some specific comments on the included commits. In general, I would like to avoid having special cases for different types of DICOM files. I think that nibabel.nicom.dicomwrappers is the best place to handle the peculiarities of different types of DICOM files (and I see you guys have started to do some work there).
I am going to propose (hopefully next week) a general class to include in nibabel that will store the stacked meta data. Each of the dicomwrapper types should then be able to produce their own stacked meta data (basically just classifying all the meta data as global or per-slice or per-volume). This should eliminate the need for special casing the different types of input DICOM files within the dcmstack code.
tried it with 4D dicom but crashes with:
/data/code/dcmstack/build/lib/dcmstack/dcmstack.py in to_nifti_wrapper(self, voxel_order)
905
906 def to_nifti_wrapper(self, voxel_order=''):
--> 907 return NiftiWrapper(self.to_nifti(voxel_order, True))
908
909 def parse_and_stack(src_paths, key_format='%(SeriesNumber)03d-%(ProtocolName)s',
/data/code/dcmstack/build/lib/dcmstack/dcmstack.py in to_nifti(self, voxel_order, embed_meta)
762 '''
763 #Get the voxel data and affine
--> 764 data = self.get_data()
765 affine = self.get_affine()
766
/data/code/dcmstack/build/lib/dcmstack/dcmstack.py in get_data(self)
685 for slice_idx in range(stack_shape[2]):
686 vox_array[:, :, slice_idx, time_idx, vec_idx] = \
--> 687 self._files_info[0][0].nii_img.get_data()[:, :, time_idx + stack_shape[3]*slice_idx]
688 elif files_per_vol == 1 and file_shape[2] != 1:
689 file_idx = vec_idx*(stack_shape[3]) + time_idx
ValueError: operands could not be broadcast together with shapes (64,64) (64,64,140)
thank you for your efforts in handling these files.
@bpinsard : Work to handle 4D+ multiframe is under way but not complete. Currently there is some code waiting to go into nibabel.nicom.dicomwrappers for handling this data. Integration with dcmstack should hopefully be able to start soon.
@moloney , is this ok to close and continue work in enh-arbitrary-dimensions
? After testing this with nipy/nibabel#168 (thanks @matthew-brett!), 3D still works but still no 4D...
However, 4D (at least one phantom fMRI epi) is working with moloney/dcmstack@a30cb7c
Thoughts?
Yes, it makes sense to work off of that branch. Closing here.
We are still working though the details for the CLI, but from a python interpreter this seems to work well for 3D MPRAGE scans.
import dicom, dcmstack dcm = dcmstack.DicomStack() dcm.add_ddcm(dicom.read_file('test/dcmstack/philips-mprage.dcm)) nii = dcm.to_nii() nii.to_filename('mprage.nii')
Goal is to move on to 4D fMRI and DTI once we have a good idea of how our modifications mesh with dcmstack. And also dig into metadata in the private tags. Much thanks to Ly Nguyen for her work on this.
Thanks for the review!
Nolan