User Tools

Site Tools


mbstring extension must be loaded in order to run mPDF
neuroimagen:mri_deface

Table of Contents

mri deface

Prueba

https://surfer.nmr.mgh.harvard.edu/fswiki/AutomatedDefacingTools

[osotolongo@detritus facehbi]$ /nas/usr/local/bin/mri_deface_linux bids/sub-0001/anat/sub-0001_T1w.nii.gz /nas/usr/local/share/mri_deface/talairach_mixed_with_skull.gca /nas/usr/local/share/mri_deface/face.gca deface/sub-0001_T1w_defaced.nii.gz
logging results to sub-0001_T1w_defaced.nii.log
reading '/nas/usr/local/share/mri_deface/talairach_mixed_with_skull.gca'...
reading 'bids/sub-0001/anat/sub-0001_T1w.nii.gz'...
changing type of input volume to 8 bits/voxel...
MRIchangeType: Building histogram
bounding unknown intensity as < 10.3 or > 1461.6
total sample mean = 111.8 (0 zeros)
spacing=8, using 2055 sample points, tol=1.00e-03...
resetting wm mean[0]: 143 --> 144
resetting gm mean[0]: 89 --> 89
input volume #1 is the most T1-like
using real data threshold=7.0
skull bounding box = (48, 17, 11) --> (211, 255, 216)
using (102, 96, 114) as brain centroid...
mean wm in atlas = 144, using box (82,67,89) --> (122, 125,139) to find MRI wm
before smoothing, mri peak at 133
robust fit to distribution - 134 +- 8.9
after smoothing, mri peak at 134, scaling input intensities by 1.075
scaling channel 0 by 1.07463
initial log_p = -4.7
 
after initial translation: (-5.7, 19.3, -5.7): log p = -4.3
 
scale 1.000: max=-3.9, old_max =-4.3 (thresh=-4.2)
 
scale 1.000: max=-3.8, old_max =-3.9 (thresh=-3.9)
 
scale 1.000: max=-3.8, old_max =-3.8 (thresh=-3.8)
reducing scale to 0.2500
....
....
....
anonymizing volume...
using wm = 107.0, gm = 93.4
wm covar:
 502.39935;
gm covar:
 659.34979;
.........................
1058443 face voxels erased, 250588 ambiguous voxels retained
resampling to original coordinate system...
writing anonymized volume to deface/sub-0001_T1w_defaced.nii.gz...
deidentification took 2 minutes and 54 seconds.

en paralelo

deface.py
#!/usr/bin/env python2
 
import subprocess
import re
import os
from slurm import send_sbatch
 
defacer = '/nas/usr/local/bin/mri_deface_linux'
def_dir = '/nas/usr/local/share/mri_deface/'
tal_gca = def_dir+'talairach_mixed_with_skull.gca'
face_gca = def_dir+'face.gca'
finder = 'find /nas/data/facehbi/bids/sub-* -name "*.nii.gz"'
outdir = '/nas/data/facehbi/defaced/'
time = '2:0:0'
cpus = 4
wdir = os.environ.get('PWD')
 
if not os.path.isdir(outdir): os.mkdir(outdir)
ifiles = subprocess.check_output('find /nas/data/facehbi/bids/sub-* -name "*.nii.gz"', shell=True).split('\n')
for ifile in ifiles:
  if os.path.exists(ifile):
    cdata = {'time':time, 'cpus':4, 'job_name':'deface'}
    ofile = re.sub('bids','defaced/bids',ifile)
    dst_dir = os.path.dirname(ofile)
    if not os.path.isdir(dst_dir): os.makedirs(dst_dir)
    order1 = defacer+' '+ifile+' '+tal_gca+' '+face_gca+' '+ofile
    jfile = re.sub('\.nii\.gz','.json',ifile)
    ojfile = re.sub('\.nii\.gz','.json',ofile)
    order2 = 'cp '+jfile+' '+ojfile
    name = os.path.basename(ifile).split('.')[0]
    cdata['filename'] = wdir+'/deface_'+name+'.sh'
    cdata['output'] = wdir+'/deface_'+name+'.out'
    cdata['command'] = order1+'\n'+order2+'\n'
    send_sbatch(cdata)
mdata = {'job_name':'deface', 'filename':wdir+'/deface_end.sh', 'output':wdir+'/deface_end.log', 'dependency':'singleton'}
send_sbatch(mdata)
neuroimagen/mri_deface.txt · Last modified: 2020/12/03 15:55 by osotolongo