Giter VIP home page Giter VIP logo

mp2rage's Introduction

mp2rage

SPM implementation of https://github.com/JosePMarques/MP2RAGE-related-scripts
Based on :

  • O'Brien KR, Kober T, Hagmann P, Maeder P, Marques J, Lazeyras F, et al. (2014) Robust T1-Weighted Structural Brain Imaging and Morphometry at 7T Using MP2RAGE. PLoS ONE 9(6): e99676. https://doi.org/10.1371/journal.pone.0099676
  • O'Brien K, Krueger G, Lazeyras F, Gruetter R, Roche A, A simple method to denoise MP2RAGE; 2013; Salt Lake City, Utah.pp. 269. http://archive.ismrm.org/2013/0269.html
  • Marques, J. P., Kober, T., Krueger, G., van der Zwaag, W., Van de Moortele, P.-F., & Gruetter, R. (2010). MP2RAGE, a self bias-field corrected sequence for improved segmentation and T1-mapping at high field. NeuroImage, 49(2), 1271–1281. https://doi.org/10.1016/j.neuroimage.2009.10.002

Requirements

SPM12 : https://www.fil.ion.ucl.ac.uk/spm/software/spm12/

Installation

Clone the repo : git clone https://github.com/benoitberanger/mp2rage, or use direct download link >> here <<, then place freshly downloaded/cloned directory in spm12/toolbox/, such as spm12/toolbox/mp2rage. You can also use a symlink, such as ln -s path/to/mp2rage path/to/spm12/toolbox/mp2rage

That's all.

If you already started SPM in your MATLAB session, don't forget to refresh SPM paths with spm_jobman('initcfg');.

How it works

This repo is an extension of spm12, you can use the Batch Editor (spm_jobman) and open the tab SPM > Tools > MP2RAGE > choose-your-job

Remove background

The objective is to remove the "salt and pepper" background noise from the UNI image.

Method 1 (newer)

Use a INV2 as pseudo mask. No user tuning required.
Based on : https://github.com/srikash/3dMPRAGEise.git

Method 2 (historical)

Use a INV1 + INV2 + regularisation factor. The regularisation factor has to be tuned by the user.
Based on :

Interactive

To determine which regularization factor to use, you can use the job SPM > Tools > MP2RAGE > Interactive remove background
This will display the original UNI image and the denoised version with a popup where you can enter the regularization level and check the result immediately :
irmbg

Normal

When you are settled with your regularization level, use "normal" job SPM > Tools > MP2RAGE > Remove background :
rmbg

Estimate T1

This job will estimate T1map and R1map using sequence parameters and the UNI image.
Based on :

  • Marques, J. P., Kober, T., Krueger, G., van der Zwaag, W., Van de Moortele, P.-F., & Gruetter, R. (2010). MP2RAGE, a self bias-field corrected sequence for improved segmentation and T1-mapping at high field. NeuroImage, 49(2), 1271–1281. https://doi.org/10.1016/j.neuroimage.2009.10.002

estimateT1

Comments on the parameters

Parameter name Description dcm2niix json sidecar field on Siemens scanners
UNI image input T1 weighted x this image has the suffix \_UNI_image
Magnetic field strength B0 (T) in Tesla (T) MagneticFieldStrength x
MR2RAGE TR (s) Repetition time (TR) of the MP2RAGE RepetitionTime TR
EchoSpacing (s) in seconds (s), TR of the GRE readout does not exist tab Sequence > Part 1 > Echos pacing
Inversin Times (s) in seconds (s), such as [TI1 TI2] InversionTime TI
Flip Angles (°) in degree (°), such as [FA1 FA2] FlipAngle Flip angle
Number of slices per slab Number of slices per slab does not exist Slices per slab
PartialFourierInSlice The value range is 0 to 1 PartialFourier SlicePartialFourier, not PhasePartialFourier
expressed as a fraction such as 8/8, 7/8, ...
Fat saturation pulse x does not exist tab Contrast > Fat Sat
the option can be "nonce, "water excitation normal", "water excitation fast"

mp2rage's People

Contributors

benoitberanger avatar dimitripapadopoulos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mp2rage's Issues

T1 map creation fails

Hello

Trying to use the toolbox to create some T1 maps gives me the following error:

24-Nov-2020 13:30:52 - Running 'Estimate T1'
[mp2rage_main_estimate_T1]: Final output = /home/remi/gin/V5_high-res/pilot_1/raw/sub-pilot001/ses-001/anat/qT1_sub-pilot001_ses-001_acq-lores_UNIT1.nii 
[mp2rage_main_estimate_T1]: Final output = /home/remi/gin/V5_high-res/pilot_1/raw/sub-pilot001/ses-001/anat/qR1_sub-pilot001_ses-001_acq-lores_UNIT1.nii 
24-Nov-2020 13:30:53 - Failed  'Estimate T1'
Error using griddedInterpolant
The grid vectors must contain unique points.
In file "/usr/local/MATLAB/R2017a/toolbox/matlab/polyfun/interp1.p" (???), function "interp1" at line 149.
In file "/home/remi/matlab/SPM/spm12/toolbox/mp2rage/mp2rage_main_estimate_T1.m" (???), function "mp2rage_main_estimate_T1" at line 42.
In file "/home/remi/matlab/SPM/spm12/toolbox/mp2rage/mp2rage_cfg_matlabbatch.m" (???), function "prog_estimateT1" at line 359.

Here is what my batch looks like: most of those values are taken from the PDF printout of the sequence details on a siemens scanner or from the DICOM header.

matlabbatch{1}.spm.tools.mp2rage.estimateT1.UNI = {'/home/remi/gin/V5_high-res/pilot_1/raw/sub-pilot001/ses-001/anat/sub-pilot001_ses-001_acq-lores_UNIT1.nii,1'};
matlabbatch{1}.spm.tools.mp2rage.estimateT1.B0 = 7;
matlabbatch{1}.spm.tools.mp2rage.estimateT1.TR = 4.3;
matlabbatch{1}.spm.tools.mp2rage.estimateT1.EchoSpacing = 0.0072;
matlabbatch{1}.spm.tools.mp2rage.estimateT1.TI = [1 3.2];
matlabbatch{1}.spm.tools.mp2rage.estimateT1.FA = [4 4];
matlabbatch{1}.spm.tools.mp2rage.estimateT1.nrSlices = 192;
matlabbatch{1}.spm.tools.mp2rage.estimateT1.PartialFourierInSlice = 0.75;
matlabbatch{1}.spm.tools.mp2rage.estimateT1.FatSat = 'yes';
matlabbatch{1}.spm.tools.mp2rage.estimateT1.outputT1.prefix = 'qT1_';
matlabbatch{1}.spm.tools.mp2rage.estimateT1.outputR1.prefix = 'qR1_';

Alternatively, I tried the original matlab code from Jose P Marques with the same parameters and it worked.

Not entirely sure what the difference is coming from.

% creation of T1 maps using JosePMarques scripts
% https://github.com/JosePMarques/MP2RAGE-related-scripts

path_2_mp2rape_code =  '/home/remi/github/MP2RAGE-related-scripts';
addpath(genpath(path_2_mp2rape_code))

bids_path = fullfile(pwd, '..', '..', 'raw');

uni_img = fullfile(bids_path, 'sub-pilot001', 'ses-001', 'anat', ...
  'sub-pilot001_ses-001_acq-lores_UNIT1.nii');

MP2RAGE.B0 = 7;           % in Tesla
MP2RAGE.TR = 4.3;           % MP2RAGE TR in seconds
MP2RAGE.TRFLASH = 7.2e-3; % TR of the GRE readout

% inversion times - time between middle of refocusing pulse and excitatoin
% of the k-space center encoding
MP2RAGE.TIs = [1 3.2];
MP2RAGE.NZslices = 192;% Slices Per Slab * [PartialFourierInSlice-0.5  0.5]
MP2RAGE.FlipDegrees = [4 4];% Flip angle of the two readouts in degrees
MP2RAGE.filename = uni_img; % file


% check the properties of this MP2RAGE protocol... this happens to be a
% very B1 insensitive protocol

plotMP2RAGEproperties(MP2RAGE)

% load the MP2RAGE data - it can be either the SIEMENS one scaled from
% 0 4095 or the standard -0.5 to 0.5
MP2RAGEimg=load_untouch_nii(MP2RAGE.filename);

[T1map, R1map]=T1estimateMP2RAGE(MP2RAGEimg,MP2RAGE,0.96);

input parameters when dealing with a BIDS dataset

Just a quick head's up that might help with long term usage of the toolbox.

There is ongoing work to create a Brain imaging data structure extension proposal (BIDS BEP) to organize and curate MP2RAGE data.

The initial pull request on the BIDS repo is here and has since been broken down into several smaller pull-requests.
bids-standard/bids-specification#508

An example of what those MP2RAGE dataset would look like is available on OSF: https://osf.io/k4bs5/

The issue is that some of the terms will be different from those mentioned in the toolbox or those you find in DICOM header or on your MRI console.

I think the most notable are that:

  • EchoSpacing I think becomes RepetitionTimeExcitation (though I am not entirely sure of that one because this number even though it "exists" on the MRI console, it appears nowhere in the DICOM header I have as far as I can tell).

  • RepetionTime becomes RepetitionTimePreparation.

See an example of the metadata contained in a JSON file

{
"InversionTime": 0.8, 
"FlipAngle": 5, 
"RepetitionTimeExcitation": 0.0062, 
"RepetitionTimePreparation": 5.5,
 "NumberShots": 159, 
"FieldStrength":7
}

So to make sure that users are not confused, if they deal with this kind of data set it might be good to update the documentation (once the work on that BIDS BEP has been finalized).

Re: Error

Hi
Thanks for sharing your scripts for processing MP2RAGE. I tried to run the Matlab scripts, it is giving error like and it has same error in running remove background. Please let me know how to fix that. I am using spm12 and R2019b Is this related to MATLAB version? Thanks
Ned

7-Nov-2020 11:11:12 - Running 'Interactive remove background'
[mp2rage_run_remove_background]: Final output = /Users/Desktop/Fmri/uni/clean_s201007152011DST131221107524366082-0006-00001-000001-01.nii,1
17-Nov-2020 11:11:16 - Failed 'Interactive remove background'
Error using nifti/subsasgn>assigndat (line 384)
Unknown filename extension (.nii,1).
In file "/Users/khan/Documents/MATLAB/spm12/@nifti/subsasgn.m" (v7370), function "assigndat" at line 384.
In file "/Users/khan/Documents/MATLAB/spm12/@nifti/subsasgn.m" (v7370), function "fun" at line 76.
In file "/Users/khan/Documents/MATLAB/spm12/@nifti/subsasgn.m" (v7370), function "subsasgn" at line 20.
In file "/Users/khan/Documents/MATLAB/spm12/spm_create_vol.m" (v7455), function "create_vol" at line 107.
In file "/Users/khan/Documents/MATLAB/spm12/spm_create_vol.m" (v7455), function "spm_create_vol" at line 17.
In file "/Users/khan/Documents/MATLAB/spm12/spm_write_vol.m" (v5731), function "spm_write_vol" at line 83.
In file "/Users/khan/Documents/MATLAB/spm12/toolbox/mp2rage-master/mp2rage_run_remove_background.m" (???), function "mp2rage_run_remove_background" at line 100.
In file "/Users/Documents/MATLAB/spm12/toolbox/mp2rage-master/mp2rage_cfg_matlabbatch.m" (???), function "prog_rmbg" at line 326.

The following modules did not run:
Failed: Interactive remove background

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.