Пример #1
0
    def directInvokeAlgorithm(self, vals):
        print('oooo invoking: smoothImage with vals', vals)

        input = self.inputs['input']
        s = (vals['sigma'])

        try:
            self.outputs['output'] = libbis.gaussianSmoothImageWASM(
                input,
                paramobj={
                    "sigmas": [s, s, s],
                    "inmm": self.parseBoolean(vals['inmm']),
                    "radiusfactor": vals['radiusfactor'],
                },
                debug=self.parseBoolean(vals['debug']))
        except:
            e = sys.exc_info()[0]
            print('---- Failed to invoke algorithm', e)
            return False

        return True
Пример #2
0
        };
	matr=np.eye(4,dtype=np.float32);
	group_resliced=libbiswasm.resliceImageWASM(group,matr,resl_paramobj,2);


print('++++ \t Group parcellation dims=',group_resliced.dimensions);

if (smooth == 0):
	fmri_smoothed = fmri;
	print('++++ \t No smoothing required...');
else:
	print('++++ \t Smoothing fMRI image...');
	c = smooth * 0.4247;
	fmri_smoothed = libbiswasm.gaussianSmoothImageWASM(fmri,
                                              paramobj={
                                              "sigmas": [c, c, c],
                                              "inmm": True,
                                              "radiusfactor": 1.5,
                                               }, debug=2);
        


out_img=libbiswasm.individualizeParcellationWASM(fmri_smoothed,group_resliced,paramobj,2);

out_img.save(output);
print('++++\n Output image is saved in ',output);

output_sm = output.replace('.nii','') + '_sm.nii'
fmri_smoothed.save(output_sm);
sys.exit();

Пример #3
0
    def directInvokeAlgorithm(self, vals):
        print('oooo invoking: individualizedParcellation with vals', vals)

        debug = self.parseBoolean(vals['debug'])
        fmri = self.inputs['fmri']
        group = self.inputs['parc']

        if (fmri.hasSameOrientation(group, 'fMRI Image', 'Group Parcellation',
                                    True) == False):
            return False

        fmriDim = fmri.dimensions
        groupDim = group.dimensions

        # Reslice Group Parcellation if needed
        if (fmriDim[0] != groupDim[0] or fmriDim[1] != groupDim[1]
                or fmriDim[2] != groupDim[2]):
            print(
                '++++ \t Group parcellation being resliced to match the fMRI image dimension...'
            )
            resl_paramobj = {
                "interpolation": 0,
                "dimensions": fmri.dimensions,
                "spacing": fmri.spacing,
                "datatype": "short",
                "backgroundValue": 0.0,
            }

            matr = np.eye(4, dtype=np.float32)
            try:
                print(
                    '++++ Reslicing group parcellation to match dimensions of individual fmri image'
                )
                group = libbis.resliceImageWASM(group, matr, resl_paramobj,
                                                debug)
            except:
                e = sys.exc_info()[0]
                print('---- Failed to invoke algorithm', e)
                return False
            print('++++ \t Group parcellation dims=', group.dimensions)

        # Smooth If needed
        smooth = vals['smooth']
        if (smooth > 0.001):
            print('++++ \t Smoothing fMRI image...')
            c = smooth * 0.4247
            smooth_paramobj = {
                "sigmas": [c, c, c],
                "inmm": True,
                "radiusfactor": 1.5,
                "vtkboundary": True,
            }

            try:
                print('++++ Smoothing fmri Image')
                fmri = libbis.gaussianSmoothImageWASM(fmri, smooth_paramobj,
                                                      debug)
            except:
                e = sys.exc_info()[0]
                print('---- Failed to invoke algorithm', e)
                return False

        # Actual Parcellation
        paramobj = {
            'numberofexemplars': vals['numregions'],
            'usefloat': self.parseBoolean(vals['usefloat']),
            'saveexemplars': self.parseBoolean(vals['saveexemplars']),
        }
        try:
            self.outputs['output'] = libbis.individualizedParcellationWASM(
                fmri, group, paramobj, debug)
        except:
            e = sys.exc_info()[0]
            print('---- Failed to invoke algorithm', e)
            return False

        return True