====== UNICORT ======
**Unified segmentation based correction of R1 brain maps for RF transmit field inhomogeneities (UNICORT)**
([[https://pmc.ncbi.nlm.nih.gov/articles/PMC3018573/|Weiskopf et al, 2011]]) is an algo available in [[:tools:spm]] (also [[:tools:spmbids]]) to improve SNR of the [[:tools:mp2rage]] acquisition using an additional B1 acquisition a purely data driven approach.
We use this before running [[:tools:freesufer]] on
* [[:grants:7t:mr:anat]] /Volumes/Hera/Projects/corticalmyelin_development/code/corticalmyelin_maturation/image_processing/B1+_transmitfield_correction/unicort
* [[:grants:7t:mr:freesurfer]] -> [[:tools:fmriprep]]
* [[:projects:mtrsnr]]
* [[:projects:hpcmyelin]]
* [[:grants:spa:mr]]: ''/Volumes/Hera/Projects/SPA/pipeline_testing/scripts/mp2rage_processing''
Input images should be uncompressed nii files (not .nii.gz)
anat = spm_BIDS(bdir,'data', 'modality','anat', 'type','T1w'); % cell of file paths
if isempty(anat), error('Cannot find T1-weighted (UNIT1 as T1w) image in', bdir); end
% anat = cellfun(@(x)replace(x, '.gz',''), anat, 'Uni', 0)
matlabbatch{1}.spm.spatial.preproc.channel.vols = cellstr(anat{1}); % cellstr not needed?
matlabbatch{1}.spm.spatial.preproc.channel.biasreg = 0.001;
matlabbatch{1}.spm.spatial.preproc.channel.biasfwhm = 60;
matlabbatch{1}.spm.spatial.preproc.channel.write = [1, 1];
matlabbatch{1}.spm.spatial.preproc.warp.mrf = 1;
matlabbatch{1}.spm.spatial.preproc.warp.cleanup = 1;
matlabbatch{1}.spm.spatial.preproc.warp.reg = [0, 0.001, 0.5, 0.05, 0.2];
matlabbatch{1}.spm.spatial.preproc.warp.affreg = 'mni';
matlabbatch{1}.spm.spatial.preproc.warp.fwhm = 0;
matlabbatch{1}.spm.spatial.preproc.warp.samp = 3;
matlabbatch{1}.spm.spatial.preproc.warp.write = [0, 0];