questions > Extract dcm2niix slice timing output into text file
Showing 1-2 of 2 posts
Display:
Results per page:
Jun 14, 2019  05:06 PM | Hannah Swearingen
Extract dcm2niix slice timing output into text file
Hi,

I am wondering if there is a way to extract the output from running dcm2niix into a text file, which gives the slice timing for a multiband sequence as shown: 

DICOM file dicoms/dcmS0006A0088I0088:
patient position (0020,0032) -771.012 -788.434 -38.494
orient (0020,0037) 1 0 0 0 1 0
acq 88 img 88 ser 6 dim 768x768x1x1 mm 2x2x2 offset 189296 loc 0 valid 1 ph 0 mag 0 nDTI 0 3d 0 bits 16 littleEndian 1 echo 1 coil 0 TE 30 TR 1000
Patient Position 0020,0032 (#,@,X,Y,Z) 1 8788 -771.012 -788.434 -38.494
SliceNormalVector 0.000000 0.000000 1.000000
sliceTimes 457.5 0 522.5 65 587.5 130 652.5 195 717.5 260 782.5 327.5 850 392.5 915 457.5 0 522.5 65 587.5 130 652.5 195 717.5 260 782.5 327.5 850 392.5 915 457.5 0 522.5 65 587.5 130 652.5 195 717.5 260 782.5 327.5 850 392.5 915 457.5 0 522.5 65 587.5 130 652.5 195 717.5 260 782.5 327.5 850 392.5 915
Multiband x4 sequence: setting slice order as UNKNOWN (instead of 5)

I am able to convert this sequence into a .json file and see the slice times that way, but I am trying to find a way to write into my script to automatically create a text file with the slice times. 

Thanks,
Hannah
Jun 14, 2019  06:06 PM | Chris Rorden
RE: Extract dcm2niix slice timing output into text file
I am not sure I understand your question. 

The parameter '-b y' will create a BIDS format JSON file that will include slice timing and other parameters. So your call to dcm2niix would be something like
  dcm2niix -b y -f %p_%s ~/myDICOMs
The BIDS tag "SliceTiming", "MultibandAccelerationFactor", and "ImageOrientationPatientDICOM" seem to have the information you want. You can find JSON decoders for most scripting languages. 

If you want to change the output that dcm2niix writes to the terminal, I suggest you fork the dcm2niix project from the Github page and compile a custom version to suit your needs.