最近在开发一个程序,要研究一下各种的脑影像处理工具,所以把一些整理的内容记录在这里,后续开发的时候备查。
今天整理的第一个就是DCM to Nifti工具,目前看到的比较好用的就是dcm2niix。因为我想要做一个云端版的,所以不能用常规的方法,需要用到容器,目前找到的比较好的镜像是:neurology/dcm2niix
,这个镜像比起其他镜像来说比较小。
在命令行中输入:
sudo docker run --rm neurology/dcm2niix dcm2niix
会看到dcm2niix的具体说明:
usage: dcm2niix [options] <in_folder>
Options :
-1..-9 : gz compression level (1=fastest..9=smallest, default 6)
-a : adjacent DICOMs (images from same series always in same folder) for faster conversion (n/y, default n)
-b : BIDS sidecar (y/n/o [o=only: no NIfTI], default y)
-ba : anonymize BIDS (y/n, default y)
-c : comment stored in NIfTI aux_file (up to 24 characters e.g. '-c VIP', empty to anonymize e.g. 0020,4000 e.g. '-c ""')
-d : directory search depth. Convert DICOMs in sub-folders of in_folder? (0..9, default 5)
-e : export as NRRD (y) or MGH (o) or JSON/JNIfTI (j) or BJNIfTI (b) instead of NIfTI (y/n/o/j/b, default n)
-f : filename (%a=antenna (coil) name, %b=basename, %c=comments, %d=description, %e=echo number, %f=folder name, %g=accession number, %i=ID of patient, %j=seriesInstanceUID, %k=studyInstanceUID, %m=manufacturer, %n=name of patient, %o=mediaObjectInstanceUID, %p=protocol, %r=instance number, %s=series number, %t=time, %u=acquisition number, %v=vendor, %x=study ID; %z=sequence name; default '%f_%p_%t_%s')
-g : generate defaults file (y/n/o/i [o=only: reset and write defaults; i=ignore: reset defaults], default n)
-h : show help
-i : ignore derived, localizer and 2D images (y/n, default n)
-l : losslessly scale 16-bit integers to use dynamic range (y/n/o [yes=scale, no=no, but uint16->int16, o=original], default o)
-m : merge 2D slices from same series regardless of echo, exposure, etc. (n/y or 0/1/2, default 2) [no, yes, auto]
-n : only convert this series CRC number - can be used up to 16 times (default convert all)
-o : output directory (omit to save to input folder)
-p : Philips precise float (not display) scaling (y/n, default y)
-q : only search directory for DICOMs (y/l/n, default y) [y=show number of DICOMs found, l=additionally list DICOMs found, n=no]
-r : rename instead of convert DICOMs (y/n, default n)
-s : single file mode, do not convert other images in folder (y/n, default n)
-u : up-to-date check
-v : verbose (n/y or 0/1/2, default 0) [no, yes, logorrheic]
-w : write behavior for name conflicts (0,1,2, default 2: 0=skip duplicates, 1=overwrite, 2=add suffix)
-x : crop 3D acquisitions (y/n/i, default n, use 'i'gnore to neither crop nor rotate 3D acquistions)
-z : gz compress images (y/o/i/n/3, default n) [y=pigz, o=optimal pigz, i=internal:zlib, n=no, 3=no,3D]
--big-endian : byte order (y/n/o, default o) [y=big-end, n=little-end, o=optimal/native]
--progress : Slicer format progress information (y/n, default n)
--ignore_trigger_times : disregard values in 0018,1060 and 0020,9153
--terse : omit filename post-fixes (can cause overwrites)
--version : report version
--xml : Slicer format features
Defaults file : /home/supakito/.dcm2nii.ini
Examples :
dcm2niix /Users/chris/dir
dcm2niix -c "my comment" /Users/chris/dir
dcm2niix -o /users/cr/outdir/ -z y ~/dicomdir
dcm2niix -f %p_%s -b y -ba n ~/dicomdir
dcm2niix -f mystudy%s ~/dicomdir
dcm2niix -o "~/dir with spaces/dir" ~/dicomdir
说几个相对重要的参数:
-
f
:指定了转换后的nii文件的名称 -
z
:指定了是否需要压缩为gz文件 -
o
:指定了输出的文件夹
所以在使用时可以用这样的命令在本地完成dcm2niix镜像的转换操作:
sudo docker run --rm -v /root/下载:/root/download -v /root/下载/TestData/T1/subj_053:/root/input/ neurology/dcm2niix dcm2niix -o /root/download -f rest /root/input
执行上述命令后,会将/root/下载/TestData/T1/subj_053
路径下的dcm文件转换为名为rest.nii
的文件,并将其存储在/root/下载
路径下