Пример #1
0
 def norm_write(self, in_prefix='', out_prefix='w'):
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     matname = fname_presuffix(self.data_def['anatomical'],
                             suffix='_seg_sn.mat',
                             use_ext=False)
     subj = {
         'matname': np.zeros((1,), dtype=object),
         'resample': np.vstack(sess_scans.flat),
         }
     subj['matname'][0] = matname
     roptions = {
         'preserve':False,
         'bb':np.array([[-78,-112, -50],[78,76,85.0]]),
         'vox':fltcols([2.0,2.0,2.0]),
         'interp':1.0,
         'wrap':[0.0,0.0,0.0],
         'prefix': out_prefix,
         }
     nwinfo = make_job('spatial', 'normalise', [{
             'write':{
                 'subj': subj,
                 'roptions': roptions,
                 }
             }])
     run_jobdef(nwinfo)
     # knock out the list of images, replacing with only one
     subj['resample'] = np.zeros((1,), dtype=object)
     subj['resample'][0] = self.data_def['anatomical']
     roptions['interp'] = 4.0
     run_jobdef(nwinfo)
     return out_prefix + in_prefix
Пример #2
0
def norm_write(data_def):
    sess_scans = scans_for_fnames(fnames_presuffix(data_def['functionals'], 'a'))
    matname = fname_presuffix(data_def['anatomical'],
                              suffix='_seg_sn.mat',
                              use_ext=False)
    subj = {
        'matname': np.zeros((1,), dtype=object),
        'resample': np.vstack(sess_scans.flat),
        }
    subj['matname'][0] = matname
    roptions = {
        'preserve':False,
        'bb':np.array([[-78,-112, -50],[78,76,85.0]]),
        'vox':fltcols([2.0,2.0,2.0]),
        'interp':1.0,
        'wrap':[0.0,0.0,0.0],
        }
    nwinfo = make_job('spatial', 'normalise', [{
            'write':{
                'subj': subj,
                'roptions': roptions,
                }
            }])
    run_jobdef(nwinfo)
    # knock out the list of images, replacing with only one
    subj['resample'] = np.zeros((1,), dtype=object)
    subj['resample'][0] = data_def['anatomical']
    roptions['interp'] = 4.0
    run_jobdef(nwinfo)
Пример #3
0
 def reslice(self, in_prefix="", out_prefix="r", out=("1..n", "mean")):
     which = [0, 0]
     if "mean" in out:
         which[1] = 1
     if "1..n" in out or "all" in out:
         which[0] = 2
     elif "2..n" in out:
         which[0] = 1
     sess_scans = scans_for_fnames(fnames_presuffix(self.data_def["functionals"], in_prefix))
     rsinfo = make_job(
         "spatial",
         "realign",
         [
             {
                 "write": {
                     "data": np.vstack(sess_scans.flat),
                     "roptions": {
                         "which": which,
                         "interp": 4.0,
                         "wrap": [0.0, 0.0, 0.0],
                         "mask": True,
                         "prefix": out_prefix,
                     },
                 }
             }
         ],
     )
     run_jobdef(rsinfo)
     return out_prefix + in_prefix
Пример #4
0
 def smooth(self, in_prefix="", out_prefix="s"):
     fwhm = self.ana_def["fwhm"]
     try:
         len(fwhm)
     except TypeError:
         fwhm = [fwhm] * 3
     fwhm = np.asarray(fwhm, dtype=np.float).reshape(1, 3)
     sess_scans = scans_for_fnames(fnames_presuffix(self.data_def["functionals"], in_prefix))
     sinfo = make_job("spatial", "smooth", {"data": np.vstack(sess_scans.flat), "fwhm": fwhm, "dtype": 0})
     run_jobdef(sinfo)
     return out_prefix + in_prefix
Пример #5
0
def slicetime(data_def):
    sess_scans = scans_for_fnames(data_def['functionals'])
    stinfo = make_job('temporal', 'st', {
            'scans': sess_scans,
            'so':range(1,31,2) + range(2,31,2),
            'tr':2.5,
            'ta':2.407,
            'nslices':float(30),
            'refslice':1
            })
    run_jobdef(stinfo)
Пример #6
0
def smooth(data_def, fwhm=8.0):
    try:
        len(fwhm)
    except TypeError:
        fwhm = [fwhm] * 3
    fwhm = np.asarray(fwhm, dtype=np.float).reshape(1,3)
    sess_scans = scans_for_fnames(fnames_presuffix(data_def['functionals'], 'wa'))
    sinfo = make_job('spatial', 'smooth',
                     {'data':np.vstack(sess_scans.flat),
                      'fwhm':fwhm,
                      'dtype':0})
    run_jobdef(sinfo)
Пример #7
0
def slicetime(data_def):
    sess_scans = scans_for_fnames(data_def['functionals'])
    stinfo = make_job(
        'temporal', 'st', {
            'scans': sess_scans,
            'so': range(1, 31, 2) + range(2, 31, 2),
            'tr': 2.5,
            'ta': 2.407,
            'nslices': float(30),
            'refslice': 1
        })
    run_jobdef(stinfo)
Пример #8
0
def smooth(data_def, fwhm=8.0):
    try:
        len(fwhm)
    except TypeError:
        fwhm = [fwhm] * 3
    fwhm = np.asarray(fwhm, dtype=np.float).reshape(1, 3)
    sess_scans = scans_for_fnames(
        fnames_presuffix(data_def['functionals'], 'wa'))
    sinfo = make_job('spatial', 'smooth', {
        'data': np.vstack(sess_scans.flat),
        'fwhm': fwhm,
        'dtype': 0
    })
    run_jobdef(sinfo)
Пример #9
0
def reslice(data_def):
    sess_scans = scans_for_fnames(fnames_presuffix(data_def['functionals'], 'a'))
    rsinfo = make_job('spatial', 'realign', [{
            'write':{
                'data': np.vstack(sess_scans.flat),
                'roptions':{
                    'which':[2, 1],
                    'interp':4.0,
                    'wrap':[0.0,0.0,0.0],
                    'mask':True,
                    }
                }
            }])
    run_jobdef(rsinfo)
Пример #10
0
 def smooth(self, in_prefix='', out_prefix='s'):
     fwhm = self.ana_def['fwhm']
     try:
         len(fwhm)
     except TypeError:
         fwhm = [fwhm] * 3
     fwhm = np.asarray(fwhm, dtype=np.float).reshape(1,3)
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     sinfo = make_job('spatial', 'smooth',
                     {'data':np.vstack(sess_scans.flat),
                     'fwhm':fwhm,
                     'dtype':0})
     run_jobdef(sinfo)
     return out_prefix + in_prefix
Пример #11
0
 def slicetime(self, in_prefix='', out_prefix='a'):
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     sdef = self.study_def
     stinfo = make_job('temporal', 'st', {
             'scans': sess_scans,
             'so': sdef['time_to_space'],
             'tr': sdef['TR'],
             'ta': sdef['TA'],
             'nslices': float(sdef['n_slices']),
             'refslice':1,
             'prefix': out_prefix,
             })
     run_jobdef(stinfo)
     return out_prefix + in_prefix
Пример #12
0
 def smooth(self, in_prefix='', out_prefix='s'):
     fwhm = self.ana_def['fwhm']
     try:
         len(fwhm)
     except TypeError:
         fwhm = [fwhm] * 3
     fwhm = np.asarray(fwhm, dtype=np.float).reshape(1,3)
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     sinfo = make_job('spatial', 'smooth',
                     {'data':np.vstack(sess_scans.flat),
                     'fwhm':fwhm,
                     'dtype':0})
     run_jobdef(sinfo)
     return out_prefix + in_prefix
Пример #13
0
 def slicetime(self, in_prefix='', out_prefix='a'):
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     sdef = self.study_def
     stinfo = make_job('temporal', 'st', {
             'scans': sess_scans,
             'so': sdef['time_to_space'],
             'tr': sdef['TR'],
             'ta': sdef['TA'],
             'nslices': float(sdef['n_slices']),
             'refslice':1,
             'prefix': out_prefix,
             })
     run_jobdef(stinfo)
     return out_prefix + in_prefix
Пример #14
0
def reslice(data_def):
    sess_scans = scans_for_fnames(
        fnames_presuffix(data_def['functionals'], 'a'))
    rsinfo = make_job('spatial', 'realign', [{
        'write': {
            'data': np.vstack(sess_scans.flat),
            'roptions': {
                'which': [2, 1],
                'interp': 4.0,
                'wrap': [0.0, 0.0, 0.0],
                'mask': True,
            }
        }
    }])
    run_jobdef(rsinfo)
Пример #15
0
def realign(data_def):
    sess_scans = scans_for_fnames(fnames_presuffix(data_def['functionals'], 'a'))
    rinfo = make_job('spatial', 'realign', [{
            'estimate':{
                'data':sess_scans,
                'eoptions':{
                    'quality':0.9,
                    'sep':4.0,
                    'fwhm':5.0,
                    'rtm':True,
                    'interp':2.0,
                    'wrap':[0.0,0.0,0.0],
                    'weight':[]
                    }
                }
            }])
    run_jobdef(rinfo)
Пример #16
0
 def slicetime(self, in_prefix="", out_prefix="a"):
     sess_scans = scans_for_fnames(fnames_presuffix(self.data_def["functionals"], in_prefix))
     sdef = self.study_def
     stinfo = make_job(
         "temporal",
         "st",
         {
             "scans": sess_scans,
             "so": sdef["time_to_space"],
             "tr": sdef["TR"],
             "ta": sdef["TA"],
             "nslices": float(sdef["n_slices"]),
             "refslice": 1,
             "prefix": out_prefix,
         },
     )
     run_jobdef(stinfo)
     return out_prefix + in_prefix
Пример #17
0
def realign(data_def):
    sess_scans = scans_for_fnames(
        fnames_presuffix(data_def['functionals'], 'a'))
    rinfo = make_job('spatial', 'realign', [{
        'estimate': {
            'data': sess_scans,
            'eoptions': {
                'quality': 0.9,
                'sep': 4.0,
                'fwhm': 5.0,
                'rtm': True,
                'interp': 2.0,
                'wrap': [0.0, 0.0, 0.0],
                'weight': []
            }
        }
    }])
    run_jobdef(rinfo)
Пример #18
0
 def norm_write(self, in_prefix="", out_prefix="w"):
     sess_scans = scans_for_fnames(fnames_presuffix(self.data_def["functionals"], in_prefix))
     matname = fname_presuffix(self.data_def["anatomical"], suffix="_seg_sn.mat", use_ext=False)
     subj = {"matname": np.zeros((1,), dtype=object), "resample": np.vstack(sess_scans.flat)}
     subj["matname"][0] = matname
     roptions = {
         "preserve": False,
         "bb": np.array([[-78, -112, -50], [78, 76, 85.0]]),
         "vox": fltcols([2.0, 2.0, 2.0]),
         "interp": 1.0,
         "wrap": [0.0, 0.0, 0.0],
         "prefix": out_prefix,
     }
     nwinfo = make_job("spatial", "normalise", [{"write": {"subj": subj, "roptions": roptions}}])
     run_jobdef(nwinfo)
     # knock out the list of images, replacing with only one
     subj["resample"] = np.zeros((1,), dtype=object)
     subj["resample"][0] = self.data_def["anatomical"]
     roptions["interp"] = 4.0
     run_jobdef(nwinfo)
     return out_prefix + in_prefix
Пример #19
0
 def reslice(self, in_prefix='', out_prefix='r', out=('1..n', 'mean')):
     which = [0, 0]
     if 'mean' in out:
         which[1] = 1
     if '1..n' in out or 'all' in out:
         which[0] = 2
     elif '2..n' in out:
         which[0] = 1
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     rsinfo = make_job('spatial', 'realign', [{
             'write':{
                 'data': np.vstack(sess_scans.flat),
                 'roptions':{
                     'which': which,
                     'interp':4.0,
                     'wrap':[0.0,0.0,0.0],
                     'mask':True,
                     'prefix': out_prefix
                     }
                 }
             }])
     run_jobdef(rsinfo)
     return out_prefix + in_prefix
Пример #20
0
 def reslice(self, in_prefix='', out_prefix='r', out=('1..n', 'mean')):
     which = [0, 0]
     if 'mean' in out:
         which[1] = 1
     if '1..n' in out or 'all' in out:
         which[0] = 2
     elif '2..n' in out:
         which[0] = 1
     sess_scans = scans_for_fnames(
         fnames_presuffix(self.data_def['functionals'], in_prefix))
     rsinfo = make_job('spatial', 'realign', [{
             'write':{
                 'data': np.vstack(sess_scans.flat),
                 'roptions':{
                     'which': which,
                     'interp':4.0,
                     'wrap':[0.0,0.0,0.0],
                     'mask':True,
                     'prefix': out_prefix
                     }
                 }
             }])
     run_jobdef(rsinfo)
     return out_prefix + in_prefix
Пример #21
0
 def realign(self, in_prefix=""):
     sess_scans = scans_for_fnames(fnames_presuffix(self.data_def["functionals"], in_prefix))
     rinfo = make_job(
         "spatial",
         "realign",
         [
             {
                 "estimate": {
                     "data": sess_scans,
                     "eoptions": {
                         "quality": 0.9,
                         "sep": 4.0,
                         "fwhm": 5.0,
                         "rtm": True,
                         "interp": 2.0,
                         "wrap": [0.0, 0.0, 0.0],
                         "weight": [],
                     },
                 }
             }
         ],
     )
     run_jobdef(rinfo)
     return in_prefix