questions > Cropping 3D acquisitions throwing error
Showing 1-5 of 5 posts
Display:
Results per page:
May 31, 2024  05:05 PM | hr3260
Cropping 3D acquisitions throwing error

Hello,


I'm trying to obtain the cropped/reoriented images. However, when I run the following command, the message "Error: Converted 777 of 906 files" is printed. Is there an error in the command?


subprocess.call('dcm2niix -z n -b y -x y -f %p -o '+ExpLoc+' '+glob(Folder[Day])[0]+' > '+ExpLoc+'/conversion.txt', shell=True)


 


 

May 31, 2024  06:05 PM | Chris Rorden
RE: Cropping 3D acquisitions throwing error

This question is underspecified. You need to provide the whole output for context. I would suggest trying to run the commands from the command line instead of Python to troubleshoot the source of your error. Since modern file systems allow spaces in file paths, I would not use a space as a delimiter, rather provide your arguments as a list:


 


subprocess.call(["dcm2niix", "-z", "n", "-o", "~/outdir", "~/indir"])
Jun 2, 2024  01:06 PM | hr3260
RE: Cropping 3D acquisitions throwing error

I've run the command in the terminal and below is a screenshot. The directories are marked out.


I'm going to run it with the verbose -v option set to y once I'm in the lab again, but it doesn't output any specific issues as to why it doesn't convert the rotate/reorient files.


 

Jun 2, 2024  01:06 PM | Chris Rorden
RE: Cropping 3D acquisitions throwing error

This question is underspecified. I am assuming that a lot of your DICOM files are not DICOM images. For example, other patient records stored in DICOM files. You may want to rename your DICOM files to get a better idea of what you are working with, e.g. "dcm2niix -r y -o ~/renamedDICOMs ~/inputDICOMs'. My sense is that this needs visual inspection, but is likely the expected output for a complicated set of DICOM files. You might want to use the '-i y' to ignore some of the 2D planning slices. 


For future Siemens acquisitions, I would heed the warning from the manufacturer "Do not use the mode H>>F because this complicates the numbering and you will have to sort images manually in most fMRI post-processing tools."


https://www.magnetomworld.siemens-healthineers.com/clinical-corner/application-tips/slice-order-fmri.html


 


https://crnl.readthedocs.io/stc/index.html


 

Jun 6, 2024  01:06 AM | hr3260
RE: Cropping 3D acquisitions throwing error

Here's a snippet from the output log from a previous participant:


 


Chris Rorden's dcm2nii :: 2MAY2016 64bit BSD License  :: (upgrade to dcm2niix suggested)
reading preferences file /home/USER/.dcm2nii/dcm2nii.ini
Data will be exported to /outdir/
Validating 1328 potential DICOM images.
Found 1319 DICOM images.


.....


Converting 123/1017  volumes: 1
file.dcm->MPRAGETRAT1.nii
For slice timing correction: the slice order is Siemens-even interleaved ascending (2,4..,1,3...)
 brightest voxel was 1253: data will be saved as 16-bit signed integer.
Saving /outdir/MPRAGETRAT1.nii
Reorienting as /outdir/oMPRAGETRAT1.nii
Saving /outdir/oMPRAGETRAT1.nii
Cropping NIfTI/Analyze image /outdir2/oMPRAGETRAT1.nii
Saving /outdir/coMPRAGETRAT1.nii


.....


 


Where the command calling dcm2nii (older version from an older script) was:


subprocess.call('dcm2nii -d N -e N -f N -i N -4 Y -g N -n Y -o '+ExpLoc+' -v Y '+glob(Folder[Day])[0]+' > '+ExpLoc+'/conversion.txt', shell=True).


dcm2nii was updated to dcm2niix, but calling dcm2niix with:


subprocess.call(["dcm2niix", "-f", "%p", "-x", "y", "-o", ExpLoc, glob(Folder[Day])[0]])


doesn't seem to crop or rotate the .dcm file. The main issue is that only one file is not being cropped and reoriented. I've run the above dcm2niix command in the terminal on the single file and it prompts the error mentioned in my earlier post.


EDIT: Ignore this post, I've since resolved the issue.