CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/main/seminar2/seminar2_1_mri.ipynb
Views: 63
MRI data analysis, sources databases, tools and QC
PLAN:
MRI data formats \
accessing data voxel and meta data \
transformations \
preprocessing \
visualization
1) MRI File Formats
All volume-based formats store 3D or 4D arrays of voxels in some fashion with a variety of additional meta-data. Anatomical images are typically 3D while EPIs are typically 4D (x,y,z, and time).
voxel: A three-dimensional pixel and the basic unit of spatial measurement in MRI.
volume: The three dimensional array covering the brain. Volumes are composed of voxels All volume files contain both meta-data and voxels. The meta-data is just a set of information about the file’s contents while the voxels are a 3D or 4D array of values.
slice: A two-dimensional 'view' of the three-dimensional volume obtained by taking all of the elements in two of the dimensions for a fixed location in the third dimension.
Timecourse or Timeseries: a set of numbers representing a measurement (like BOLD activation) taken over time.
Here are the most typical file formats of neuroimaging data:
DICOM (.dcm, .ima) \
NIFTI (.nii/nii.gz, gii.gz) \
MGH (.mgh, .mgz) \
Custom (.dtseries, .label, .surf)
DICOM file format
Common MRI DICOM sctructure
Lets stack all DICOM's and plot em aall:
DICOM Headers
Another good way to look at the meta-data in a volume file is to load it with the relevant programming environment and examine the data-structures there. Here are a few examples. Accordingly, we need to be able to, at a minimum, store some amount of information about the coordinate system employed in any MRI volume file, and ideally some amount of information about how to precisely align the brain to some standard orientation.
Data manipulations
Assume that you recieved new dicom from hospital or downloaded challenge data and you need to convert to convinient NIFTI, let's review the tool distinctive from simple one represented above:
dcm2niix Robust .dcm to nii/nii.gz converter. Params %i %n %p stands for patient ID, subject name, protocol name DICOM header keys. Try to run with params %p_%t_%s \
https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#General_Usage
Plotting results of convertation:
Nifti File Format
The Neuroimaging Informatics Technology Initiative (nifti) is format to store radiological information, the first three dimensions are reserved to define the three spatial dimensions — x, y and z —, while the fourth dimension is reserved to define the time points — t. The remaining dimensions, from fifth to seventh, are for other uses. The fifth dimension, however, can still have some predefined uses, such as to store voxel-specific distributional parameters or to hold vector-based data.
Nifti Header
MGH File Format
MGH File Format is a default format of freesurfer preprocessing software. That can do the following
MGH Header
DICOM patient coordinate and Nifti coodrinate system when Patient is Head First Supine. The arrows of axes indicate the positive directions, LPS for DICOM and RAS for Nifti. For Dicom images, the origin (0,0,0) refers to magnet isocenter.
Voxel size and Pixel spacing are important as we for preprocessing we can use only isomorphic voxel
BIDS Brain Imaging Data Structure. Simplify representation of DICOM neuroimaging data and grants huge advantages for experiments and version control of dataset. Moreover, reduces dataset storage range.
There is a few robust DICOM converters:
HeudiConv
dcm2bids
They both use DICOM headers, to distinquish sequence protocols. So fully anonomized DICOMs can't be converted using this software. Let's look how heudiconv runs: First you should implement heudiconv.py. The only required function for a heuristic, infotodict is used to both define the conversion outputs and specify the criteria for scan to output association. Conversion outputs are defined as keys, a tuple consisting of a template path used for the basis of outputs, as well as a tuple of output types. Valid types include nii, nii.gz, and dicom.
Heudiconv output BIDS directory tree: