Closed jonbpanda closed 1 month ago
FYI: If you export as "Enhanced" DICOM from XA, you'll get 1 DICOM per frame/volume, which is much easier to work with.
@jonbpanda this sounds like the expected behavior. Saving multi-band EPI data as one classic DICOM per slice is extremely inefficient for any tool and storage device. As @mharms notes, you really want to save the data as enhanced DICOM, which for Siemens will save each 3D volume as a separate file. One inherent limitation of the classic DICOM standard is that each slice is saved as a separate file and no file reveals the total number of files in a series. Therefore, one must exhaustively examine each and every slice to work out which series it belongs to.
For sessions that are saved with lots of series in a single session, you can dramatically accelerate dcm2niix by converting in two passes: first rename the DICOMs so that all the images from a single series is saved in a single folder, and that data from each series is saved in a separate folder from each other. Then process each one of the series folders independently. The dcm2niix rename (-r y
) function is ideal for the first step.
ChatGPT can help you create a Python or bash script for this. Here is a simple bash script that assumes an existing input folder with DICOMs (~/indir
), a non-existent temporary folder to store the renamed DICOMs (~/temp
) and an output folder for the NIfTI images (~/outdir
). You would call it like this:
./dcm.sh ~/indir ~/temp ~/out
and here is the script:
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <indir> <tempdir> <outdir>"
exit 1
fi
indir="$1"
tempdir="$2"
outdir="$3"
# 1. Terminate if a directory indir does not exist
if [ ! -d "$indir" ]; then
echo "Error: Input directory '$indir' does not exist."
exit 1
fi
# 2. Terminate if the directory tempdir does exist
if [ -d "$tempdir" ]; then
echo "Error: Temporary directory '$tempdir' already exists."
exit 1
fi
# 3. Create tempdir
mkdir "$tempdir"
if [ $? -ne 0 ]; then
echo "Error: Failed to create temporary directory '$tempdir'."
exit 1
fi
# 4. Run dcm2niix with the rename (-r y) argument, using a filename specifier that sorts by series (-f %s..)
dcm2niix -r y -f "%s_%p/%4r_%o.dcm" -o "$tempdir" "$indir"
if [ $? -ne 0 ]; then
echo "Error: dcm2niix failed to process '$indir'."
exit 1
fi
# 5. Run dcm2niix sequentially for each folder inside tempdir saving all results to outdir
for dir in "$tempdir"/*; do
if [ -d "$dir" ]; then
dcm2niix -o "$outdir" "$dir"
if [ $? -ne 0 ]; then
echo "Error: dcm2niix failed to process '$dir'."
exit 1
fi
fi
done
# 6. Delete tempdir and all its contents
rm -rf "$tempdir"
if [ $? -ne 0 ]; then
echo "Error: Failed to delete temporary directory '$tempdir'."
exit 1
fi
echo "Processing completed successfully."
If you still think that dcm2niix is slower than one could reasonably expect, share a dataset with my institutional email and I will see if there are any other tricks.
Closing as unable to replicate.
Describe the bug
Not sure this is a bug! Acquired multi-shell diffusion data according to the HCP-D/A protocol (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6484842/)
Note that the data were acquired with the Siemens product multi-band sequence (not the CMRR version), so every slice for each direction/b-value combination is saved as a separate image (rather than mosaic'ed). There were 92 slices per volume, which relates to the Warning below
However, dcm2niix took absolutely ages (>1 hour) to parse the DICOM folder on a relatively speedy machine.
To reproduce
Steps to reproduce the behavior:
Expected behavior
Would like to think that dcm2niix could resolve this problem of non-mosaic'ed data and reconstitute the desired volumes - even better if it could munge it into a 4D file and generate the associated bvec and bval files.
Output log
N/A
Version
Please report the complete version string:
dcm2niiX version v1.0.20240202 GCC12.3.0 x86-64 (64-bit Linux)
Troubleshooting
Please try the following steps to resolve your issue:
Latest stable release AFAIK
Haven't had a chance to try this yet. Will try when I have a moment.