Converting DICOM to MINC
Minc tool dcm2mnc may be used to convert DICOM to MINC.
It is available on CBRAIN as tool “DICOM → MINC.”
It is also available on the BIC server:
mkdir <prefix>_<id>_t1dcm2mnc [options] -usecoordinates <dicomdirectoryname> <prefix>_<id>_t1mv <prefix>_<id>_t1/*/*.mnc <prefix>_<id>_t1.mnc
Type dcm2mnc -help for more information. Make sure to always use the -usecoordinates option.
Converting NIfTI or ANALYZE to MINC
Minc tool nii2mnc may be used to convert NIfTI or ANALYZE to MINC.
It is available on CBRAIN as tool “NIfTI → MINC.”
It is also available on the BIC server:
nii2mnc [options] <filename>.nii [<prefix>_<id>_t1.mnc]nii2mnc [options] <filename>.hdr [<prefix>_<id>_t1.mnc]
Type nii2mnc -help for more information. It there are options such as -flipx, -sagittal, etc, you are using an old version. The new version of nii2mnc auto-detects the correct orientation of the image. Make sure to use this new version.
Converting Freesurfer MGZ to MINC
You may use the Freesurfer tool mri_convert to convert MGZ to MINC:
mri_convert —out_orientation RAS <filename>.mgz <prefix>_<id>_t1.mnc
Type mri_convert -u for more information.
QC of converted MINC files
Minc tool mincpik may be used to verify whether your files were successfully converted to MINC.
It is available on CBRAIN as tool “Launch Mincpik.”
It is also available on the BIC server:
mincpik -triplanar [options] <prefix>_<id>_t1.mnc <prefix>_<id>_t1.png
Type mincpik -help for more information.
Scripts for converting a large dataset to MINC
If you have many files to convert, you may write a simple Perl script (<scriptname>.pl) such as the following:
Sample Perl script for DICOM to MINC
#! /usr/bin/env perl
#######################################################################
use strict;
use warnings;
my $dir = "~/dir"; # directory where data is
my $oldfilename = "olddirectoryname"; # however your directories containing DICOMs (.dcm) were named
my $numsubj = "10"; # number of subjects
my $id;
my $prefix = "prefix"; # the prefix used for your study
for ( $id = 1; $id <= $numsubj; $id++ ) {
$id = sprintf( "%04d", $id ); # if you use leading zeros as fillers in your naming convention (change the number 4 to the total number of digits)
`mkdir $dir/${prefix}_${id}_t1`;
print "Running dcm2mnc -usecoordinates $dir/${oldfilename}_$id $dir/${prefix}_${id}_t1\n";
`dcm2mnc -usecoordinates $dir/${oldfilename}_$id $dir/${prefix}_${id}_t1`;
`mv $dir/${prefix}_${id}_t1/*/*.mnc $dir/${prefix}_${id}_t1.mnc`; #Rename and move MINC file out of new subdirectory
`rm -rf $dir/${prefix}_${id}_t1`; #Delete empty subdirectory
`mincpik -triplanar $dir/${prefix}_${id}_t1.mnc $dir/${prefix}_${id}_t1.png`; #Create PNG image of axial/sagittal/coronal views for easy QC
}
Sample Perl script for NIfTI or ANALYZE to MINC
#! /usr/bin/env perl
#######################################################################
use strict;
use warnings;
my $dir = "~/dir"; # directory where data is
my $oldfilename = "oldfilename"; # however your files were named (.nii or .hdr)
my $numsubj = "10"; # number of subjects
my $id;
my $prefix = "prefix"; # the prefix used for your study
for ( $id = 1; $id <= $numsubj; $id++ ) {
$id = sprintf( "%04d", $id ); # if you use leading zeros as fillers in your naming convention (change the number 4 to the total number of digits)
print "Running nii2mnc $dir/${oldfilename}_${id}.nii $dir/${prefix}_${id}_t1.mnc\n";
`nii2mnc $dir/${oldfilename}_${id}.nii $dir/${prefix}_${id}_t1.mnc`;
`mincpik -triplanar $dir/${prefix}_${id}_t1.mnc $dir/${prefix}_${id}_t1.png`; #Create PNG image of axial/sagittal/coronal views for easy QC
}
