User Tools

Site Tools


neuroimagen:mri_deface

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
neuroimagen:mri_deface [2020/05/14 08:35]
osotolongo
neuroimagen:mri_deface [2020/12/03 15:55] (current)
osotolongo
Line 1: Line 1:
 ====== mri deface ====== ====== mri deface ======
 +
 +===== Prueba =====
  
 https://surfer.nmr.mgh.harvard.edu/fswiki/AutomatedDefacingTools https://surfer.nmr.mgh.harvard.edu/fswiki/AutomatedDefacingTools
Line 52: Line 54:
  
 {{ :neuroimagen:2020-05-14-103453_grim.png |}} {{ :neuroimagen:2020-05-14-103453_grim.png |}}
 +
 +===== en paralelo =====
 +
 +<code python 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)
 +</code>
 +
neuroimagen/mri_deface.1589445354.txt.gz ยท Last modified: 2020/08/04 10:46 (external edit)