def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == 'phase' or opt == 'magnitude' or opt == 'anat': return scans_for_fname(filename_to_list(val)) if opt == 'epi' or opt == 'magnitude': return scans_for_fname(filename_to_list(val)) return super(FieldMap, self)._format_arg(opt, spec, val)
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == "template": return scans_for_fname(filename_to_list(val)) if opt == "source": return scans_for_fname(filename_to_list(val)) if opt == "apply_to_files": return scans_for_fnames(filename_to_list(val)) if opt == "parameter_file": return np.array([list_to_filename(val)], dtype=object) if opt in ["write_wrap"]: if len(val) != 3: raise ValueError("%s must have 3 elements" % opt) return val
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == 'template': return scans_for_fname(filename_to_list(val)) if opt == 'source': return scans_for_fname(filename_to_list(val)) if opt == 'apply_to_files': return scans_for_fnames(filename_to_list(val)) if opt == 'parameter_file': return np.array([list_to_filename(val)], dtype=object) if opt in ['write_wrap']: if len(val) != 3: raise ValueError('%s must have 3 elements' % opt) return super(Normalize, self)._format_arg(opt, spec, val)
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm""" if opt == "in_files": if isinstance(val, list): return scans_for_fnames(val) else: return scans_for_fname(val) return super(CAT12SANLMDenoising, self)._format_arg(opt, spec, val)
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ clean_masks_dict = {"no": 0, "light": 1, "thorough": 2} if opt in ["data", "tissue_prob_maps"]: if isinstance(val, list): return scans_for_fnames(val) else: return scans_for_fname(val) if "output_type" in opt: return [int(v) for v in val] if opt == "save_bias_corrected": return int(val) if opt == "mask_image": return scans_for_fname(val) if opt == "clean_masks": return clean_masks_dict[val] return val
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ clean_masks_dict = {'no':0, 'light':1, 'thorough':2} if opt in ['data', 'tissue_prob_maps']: if isinstance(val, list): return scans_for_fnames(val) else: return scans_for_fname(val) if 'output_type' in opt: return [int(v) for v in val] if opt == 'save_bias_corrected': return int(val) if opt == 'mask_image': return scans_for_fname(val) if opt == 'clean_masks': return clean_masks_dict[val] return val
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm""" if opt == "in_files": if isinstance(val, list): return scans_for_fnames(val) else: return scans_for_fname(val) if opt == "spm_type": type_map = {"same": 0, "uint8": 2, "uint16": 512, "float32": 16} val = type_map[val] return super(CAT12SANLMDenoising, self)._format_arg(opt, spec, val)
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm""" if opt == "in_files": if isinstance(val, list): return scans_for_fnames(val) else: return scans_for_fname(val) elif opt in ["tpm", "shooting_tpm"]: return Cell2Str(val) return super(CAT12Segment, self)._format_arg(opt, spec, val)
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == 'in_files': return scans_for_fnames(filename_to_list(val)) if opt == 'target': return scans_for_fname(filename_to_list(val)) if opt == 'deformation': return np.array([list_to_filename(val)], dtype=object) if opt == 'deformation_field': return np.array([list_to_filename(val)], dtype=object) return val
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == 'in_files': return scans_for_fnames(filename_to_list(val)) if opt == 'target': return scans_for_fname(filename_to_list(val)) if opt == 'deformation': return np.array([list_to_filename(val)], dtype=object) if opt == 'deformation_field': return np.array([list_to_filename(val)], dtype=object) return val
def _parse_inputs(self): """validate spm realign options if set to None ignore """ einputs = super(Normalize, self)._parse_inputs(skip=("jobtype", "apply_to_files")) if isdefined(self.inputs.apply_to_files): inputfiles = deepcopy(self.inputs.apply_to_files) if isdefined(self.inputs.source): inputfiles.extend(self.inputs.source) einputs[0]["subj"]["resample"] = scans_for_fnames(inputfiles) jobtype = self.inputs.jobtype if jobtype in ["estwrite", "write"]: if not isdefined(self.inputs.apply_to_files): if isdefined(self.inputs.source): einputs[0]["subj"]["resample"] = scans_for_fname(self.inputs.source) return [{"%s" % (jobtype): einputs[0]}]
def _parse_inputs(self): """validate spm realign options if set to None ignore """ einputs = super(Normalize, self)._parse_inputs(skip=('jobtype', 'apply_to_files')) if isdefined(self.inputs.apply_to_files): inputfiles = deepcopy(self.inputs.apply_to_files) if isdefined(self.inputs.source): inputfiles.extend(self.inputs.source) einputs[0]['subj']['resample'] = scans_for_fnames(inputfiles) jobtype = self.inputs.jobtype if jobtype in ['estwrite', 'write']: if not isdefined(self.inputs.apply_to_files): if isdefined(self.inputs.source): einputs[0]['subj']['resample'] = scans_for_fname(self.inputs.source) return [{'%s' % (jobtype):einputs[0]}]
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == "channel_files": # structure have to be recreated, because of some weird traits error new_channels = [] for channel in val: new_channel = {} new_channel["vols"] = scans_for_fname(filename_to_list(channel)) new_channels.append(new_channel) return new_channels elif opt == "channel_info": # structure have to be recreated, because of some weird traits error new_channels = [] for channel in val: new_channel = {} new_channel["biasreg"] = channel[0] new_channel["biasfwhm"] = channel[1] new_channel["write"] = [int(channel[2][0]), int(channel[2][1])] new_channels.append(new_channel) return new_channels elif opt == "tissues": new_tissues = [] for tissue in val: new_tissue = {} new_tissue["tpm"] = scans_for_fnames(tissue[0]) new_tissue["ngauss"] = tissue[1] new_tissue["native"] = [int(tissue[2][0]), int(tissue[2][1])] new_tissue["warped"] = [int(tissue[3][0]), int(tissue[3][1])] new_tissues.append(new_tissue) return new_tissues
def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm """ if opt == 'channel_files': # structure have to be recreated, because of some weird traits error new_channels = [] for channel in val: new_channel = {} new_channel['vols'] = scans_for_fname(filename_to_list(channel)) new_channels.append(new_channel) return new_channels elif opt == 'channel_info': # structure have to be recreated, because of some weird traits error new_channels = [] for channel in val: new_channel = {} new_channel['biasreg'] = channel[0] new_channel['biasfwhm'] = channel[1] new_channel['write'] = [int(channel[2][0]), int(channel[2][1])] new_channels.append(new_channel) return new_channels elif opt == 'tissues': new_tissues = [] for tissue in val: new_tissue = {} new_tissue['tpm'] = scans_for_fnames(tissue[0]) new_tissue['ngauss'] = tissue[1] new_tissue['native'] = [int(tissue[2][0]), int(tissue[2][1])] new_tissue['warped'] = [int(tissue[3][0]), int(tissue[3][1])] new_tissues.append(new_tissue) return new_tissues