Comments (2)
FYI: If you export as "Enhanced" DICOM from XA, you'll get 1 DICOM per frame/volume, which is much easier to work with.
from dcm2niix.
@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.
from dcm2niix.
Related Issues (20)
- What is `offset` and `Valid 0` HOT 7
- Suppress ROI1, ROI2, etc. in conversion HOT 1
- Add Return Codes other than 0 HOT 4
- git clone failure? HOT 2
- Error in bvec extraction when UIH diffusion data is converted to nifti HOT 3
- Problems with b2500 and b700 dwi data HOT 5
- GE slice timing error
- Incorrect 3D reconstruction for enhanced multi-frame MRI HOT 4
- Feature request: Instead of providing a source directory, would it be possible to provide dcm2niix a list of files to be processed? HOT 1
- Store DICOM field (0018,9093) NumberOfKSpaceTrajectories ? HOT 2
- XA30 myomaps BEATs triggers conversion warnings, unusable nifti HOT 6
- Different study/data time, -m option not working HOT 1
- XA-series missing minor version tracking in sidecar HOT 8
- Incorrect value of PhaseEncodingDirection on Siemens 3D T2w SPACE scans HOT 4
- Addition of MAGNITUDE to ImageType of Siemens data HOT 4
- Error in Mediso Dynamic PET Conversion HOT 1
- segmentation fault on s390x systems (big endian) HOT 2
- Add github pages demo for dcm2niix WASM with Niivue
- SIEMENS XA50 DIFFUSION DATA HOT 4
- PR813 issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dcm2niix.