super().__init__(); self.name='thresholdImage'; def createDescription(self): return modules_desc.descriptions['thresholdImage']; def directInvokeAlgorithm(self,vals): print('oooo invoking: thresholdImage with vals',(vals)); input = self.inputs['input']; try: self.outputs['output'] = libbis.thresholdImageWASM(input, { "low": vals['low'], "high": vals['high'], "replacein" : self.parseBoolean(vals['replacein']), "replaceout" : self.parseBoolean(vals['replaceout']), "invalue" : vals['inval'], "outvalue" : vals['outval'], "datatype" : -1 },self.parseBoolean(vals['debug'])); except: print('---- Failed to invoke algorithm'); return False return True if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(thresholdImage(),sys.argv,False));
super().__init__() self.name = 'displacementField' def createDescription(self): return modules_desc.descriptions['displacementField'] def directInvokeAlgorithm(self, vals): print('oooo invoking: displacementField', (vals)) image = self.inputs['input'] dimension = image.dimensions spacing = image.spacing self.outputs['output'] = libbis.computeDisplacementFieldWASM( self.inputs['transform'], { "dimensions": [dimension[0], dimension[1], dimension[2]], "spacing": [spacing[0], spacing[1], spacing[2]] }, self.parseBoolean(vals['debug'])) try: print(self.outputs['output'].dimensions) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(displacementField(), sys.argv, False))
def createDescription(self): return modules_desc.descriptions['smoothImage'] 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 if __name__ == '__main__': import bis_commandline import bis_commandline sys.exit(bis_commandline.loadParse(smoothImage(), sys.argv, False))
self.outputs['output']=libbis.runNonLinearRegistrationWASM(reference, target, initial, { 'cps' : vals['cps'], 'lambda' : vals['lambda'], 'intscale' : vals['intscale'], 'numbins' : vals['numbins'], 'levels' : vals['levels'], 'smoothing' : vals['extrasmoothing'], 'optimization' : bis_baseutils.getOptimizationCode(vals['optimization']), 'stepsize' : vals['stepsize'], 'debug' : self.parseBoolean(vals['debug']), 'normalize' : self.parseBoolean(vals['norm']), 'metric' : bis_baseutils.getMetricCode(vals['metric']), 'steps' : vals['steps'], 'iterations' : vals['iterations'], 'resolution' : vals['resolution']}, self.parseBoolean(vals['debug'])); if (self.parseBoolean(vals['doreslice'])==True): self.outputs['resliced']=bis_baseutils.resliceRegistrationOutput(libbis,reference, target,self.outputs['output']); except: print('---- Failed to invoke nonlinear registration algorithm.'); return False return True if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(nonlinearRegistration(),sys.argv,False));
class extractSlice(bis_basemodule.baseModule): def __init__(self): super().__init__() self.name = 'extractSlice' def createDescription(self): return modules_desc.descriptions['extractSlice'] def directInvokeAlgorithm(self, vals): print('oooo invoking: extractSlice with vals', (vals)) input = self.inputs['input'] try: self.outputs['output'] = libbis.extractImageSliceWASM( input, { "frame": vals['frame'], "component": vals['component'], "slice": vals['slice'], "plane": vals['plane'] }, self.parseBoolean(vals['debug'])) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(extractSlice(), sys.argv, False))
def __init__(self): super().__init__(); self.name='regressOut'; def createDescription(self): return modules_desc.descriptions['regressOut']; def directInvokeAlgorithm(self,vals): print('oooo invoking: regressOut with vals', (vals)); input = self.inputs['input']; regressor = self.inputs['regressor']; weight=self.inputs['weight']; try: out = libbis.weightedRegressOutWASM(input, regressor, weight, self.parseBoolean(vals['debug'])); self.outputs['output']=bis_objects.bisMatrix(); self.outputs['output'].create(out); except: print('---- Failed to invoke algorithm'); return False return True; if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(regressOut(),sys.argv,False));
def createDescription(self): return modules_desc.descriptions['gradientImage'] def directInvokeAlgorithm(self, vals): print('oooo invoking: gradientImage with vals', vals) input = self.inputs['input'] s = (vals['sigma']) try: self.outputs['output'] = libbis.gradientImageWASM( 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 if __name__ == '__main__': import bis_commandline import bis_commandline sys.exit(bis_commandline.loadParse(gradientImage(), sys.argv, False))
out = None; if (vals['type'] == "low" or vals['type'] == "band"): out = libbis.butterworthFilterWASM(input, { "type": "low", "cutoff": vals['low'], "samplerate": vals['tr'] }, self.parseBoolean(vals['debug'])); if (vals['type'] == "low"): self.outputs['output']=bis_objects.bisMatrix() self.outputs['output'].create(out); return True inp = out; out= libbis.butterworthFilterWASM(inp, { "type": "high", "cutoff": vals['high'], "samplerate": vals['tr'], }, self.parseBoolean(vals['debug'])); self.outputs['output']=bis_objects.bisMatrix(); self.outputs['output'].create(out); except: return False return True if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(butterworthFilter(),sys.argv,False));
import biswrapper as libbis; class normalizeImage(bis_basemodule.baseModule): def __init__(self): super().__init__(); self.name='normalizeImage'; def createDescription(self): return modules_desc.descriptions['normalizeImage']; def directInvokeAlgorithm(self,vals): print('oooo invoking: normalizeImage with vals', (vals)); input = self.inputs['input']; try: self.outputs['output'] = libbis.normalizeImageWASM(input, { "perlow": vals['perlow'], "perhigh": vals['perhigh'], "outmaxvalue": vals['maxval'], }, self.parseBoolean(vals['debug'])); except: print('---- Failed to invoke algorithm'); return False return True; if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(normalizeImage(),sys.argv,False));
"windowsize": vals['windowsize'], "levels": vals['levels'], "resolution": vals['resolution'], "inverse": self.parseBoolean(vals['inverse']), }, self.parseBoolean(vals['debug'])) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm', e) return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(approximateField(), sys.argv, False)) #!/usr/bin/env python3 # LICENSE # # _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._ # # BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License"); # # - you may not use this software except in compliance with the License. # - You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) # # __Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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 if __name__ == '__main__': import bis_commandline import bis_commandline sys.exit( bis_commandline.loadParse(individualizedParcellation(), sys.argv, False))
print('oooo invoking: sliceBiasCorrect with vals', (vals)) mode = vals['axis'] axis = 3 if (mode == "x"): axis = 0 elif (mode == "y"): axis = 1 elif (mode == "z"): axis = 2 input = self.inputs['input'] try: self.outputs['output'] = libbis.sliceBiasFieldCorrectImageWASM( input, { "axis": axis, "threshold": vals['threshold'], "returnbiasfield": self.parseBoolean( vals['returnbiasfield']) }, self.parseBoolean(vals['debug'])) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(sliceBiasCorrect(), sys.argv, False))
def directInvokeAlgorithm(self,vals): print('oooo invoking: computeGLM with vals', vals); input = self.inputs['input']; mask = self.inputs['mask'] usemask=False; if (mask != None): usemask=True; regressor = self.inputs['regressor']; sz=regressor.data_array.shape; numtasks=vals['numtasks']; if (numtasks<=0 or numtasks>=sz[1]): numtasks=sz[1]; try: self.outputs['output'] = libbis.computeGLMWASM(input, mask, regressor, { 'numtasks' : numtasks, 'usemask' : usemask }, self.parseBoolean(vals['debug'])); except: print('---- Failed to invoke algorithm'); return False return True if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(computeGLM(),sys.argv,False));
def createDescription(self): return modules_desc.descriptions['clusterThreshold'] def directInvokeAlgorithm(self, vals): print('oooo invoking: clusterThresholdImage with vals', (vals)) input = self.inputs['input'] try: self.outputs['output'] = libbis.clusterThresholdImageWASM( input, { "threshold": vals['threshold'], "clustersize": vals['size'], "oneconnected": self.parseBoolean(vals['oneconnected']), "outputclusterno": self.parseBoolean(vals['outclustno']), "frame": vals['frame'], "component": vals['component'], "datatype": -1 }, self.parseBoolean(vals['debug'])) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(clusterThreshold(), sys.argv, False))
'debug': self.parseBoolean(vals['debug']), 'iterations': vals['iterations'], 'mode': bis_baseutils.getLinearModeCode(vals['mode']), 'resolution': vals['resolution'], 'return_vector': False }, self.parseBoolean(vals['debug'])) self.outputs['output'] = bis_objects.bisLinearTransformation() self.outputs['output'].create(out) if (self.parseBoolean(vals['doreslice']) == True): self.outputs[ 'resliced'] = bis_baseutils.resliceRegistrationOutput( libbis, reference, target, self.outputs['output']) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm', e) return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(linearRegistration(), sys.argv, False))
class computeCorrelation(bis_basemodule.baseModule): def __init__(self): super().__init__() self.name = 'computeCorrelation' def createDescription(self): return modules_desc.descriptions['computeCorrelation'] def directInvokeAlgorithm(self, vals): print('oooo invoking: computeCorrelation with vals', (vals)) input = self.inputs['input'] weight = self.inputs['weight'] try: out = libbis.computeCorrelationMatrixWASM( input, weight, {"toz": self.parseBoolean(vals['zscore'])}, self.parseBoolean(vals['debug'])) self.outputs['output'] = bis_objects.bisMatrix() self.outputs['output'].create(out) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(computeCorrelation(), sys.argv, False))
def createDescription(self): return modules_desc.descriptions['regularizeObjectmap'] def directInvokeAlgorithm(self, vals): print('oooo invoking: regularizeObjectmap with vals', vals) input = self.inputs['input'] try: self.outputs['output'] = libbis.regularizeObjectmapWASM( input, paramobj={ "smoothness": vals['smoothness'], "convergence": vals['convergence'], "iterations": vals['iterations'], "internaliterations": vals['internaliterations'], }, debug=self.parseBoolean(vals['debug'])) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm', e) return False return True if __name__ == '__main__': import bis_commandline import bis_commandline sys.exit(bis_commandline.loadParse(regularizeObjectmap(), sys.argv, False))
"cutoff": vals['low'], "samplerate": vals['tr'] }, self.parseBoolean(vals['debug'])) if (vals['type'] == "low"): self.outputs['output'] = out return True inp = out out = libbis.butterworthFilterImageWASM( inp, { "type": "high", "cutoff": vals['high'], "samplerate": vals['tr'], }, self.parseBoolean(vals['debug'])) self.outputs['output'] = out except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm', e) return False return True if __name__ == '__main__': import bis_commandline sys.exit( bis_commandline.loadParse(butterworthFilterImage(), sys.argv, False))
class seedCorrelation(bis_basemodule.baseModule): def __init__(self): super().__init__(); self.name='seedCorrelation'; def createDescription(self): return modules_desc.descriptions['seedCorrelationImage']; def directInvokeAlgorithm(self,vals): print('oooo invoking: seedCorrelation with vals', (vals)); input = self.inputs['input']; weight=self.inputs['weight']; regressor = self.inputs['regressor']; try: out = libbis.computeSeedCorrelationImageWASM(input, regressor, weight, { "toz" : self.parseBoolean(vals['zscore']) },self.parseBoolean(vals['debug'])); self.outputs['output']=out; except: print('---- Failed to invoke algorithm'); return False return True; if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(seedCorrelation(),sys.argv,False));
input = self.inputs['input'] reference = self.inputs['reference'] if (reference == None): reference = input xform = self.inputs['xform'] spa = reference.spacing dim = reference.dimensions dt = "-1" if (vals['forcefloat']): dt = "float" try: self.outputs['output'] = libbis.resliceImageWASM( input, xform, { "spacing": [spa[0], spa[1], spa[2]], "dimensions": [dim[0], dim[1], dim[2]], "datatype": dt, "interpolation": vals['interpolation'] }, self.parseBoolean(vals['debug'])) except: print('---- Failed to invoke algorithm') return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(resliceImage(), sys.argv, False))
self.name='flipImage'; def createDescription(self): return modules_desc.descriptions['flipImage']; def directInvokeAlgorithm(self,vals): print('oooo invoking: flipImage with vals', vals); input = self.inputs['input']; try: self.outputs['output'] = libbis.flipImageWASM(input, paramobj={ "flipi": self.parseBoolean(vals['flipi']), "flipj": self.parseBoolean(vals['flipj']), "flipk": self.parseBoolean(vals['flipk']), }, debug=self.parseBoolean(vals['debug'])) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm',e); return False return True if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(flipImage(),sys.argv,False));
for i in range (0,numframes): t=self.computeTime(i,numframes); for j in range(0,order+1): mat[i][j]=self.polynomial(t,j); return mat; def directInvokeAlgorithm(self,vals): print('oooo invoking: driftCorrectImage with vals', (vals)); input = self.inputs['input']; weight=self.inputs['weight']; order = vals['order']; regressor = self.createRegressor(input,order); try: self.outputs['output'] = libbis.weightedRegressOutImageWASM(input, regressor,weight, self.parseBoolean(vals['debug'])); except: print('---- Failed to invoke algorithm'); return False return True; if __name__ == '__main__': import bis_commandline; sys.exit(bis_commandline.loadParse(driftCorrectImage(),sys.argv,False));
return False print('oooo') print('oooo Input=', input.getDescription()) print('oooo ROI=', roi.getDescription()) try: out = libbis.computeROIWASM( input, roi, {'storecentroids': self.parseBoolean(vals['storecentroids'])}, self.parseBoolean(vals['debug'])) a = out.shape if (a[0] * a[1] < 1): print(' ----- Bad Input Images') return False self.outputs['output'] = bis_objects.bisMatrix() self.outputs['output'].create(out) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm ' + str(e)) return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(computeROI(), sys.argv, False))
try: self.outputs['output'] = libbis.cropImageWASM( input, paramobj={ "i0": (vals['i0']), "i1": (vals['i1']), "di": (vals['di']), "j0": (vals['j0']), "j1": (vals['j1']), "dj": (vals['dj']), "k0": (vals['k0']), "k1": (vals['k1']), "dk": (vals['dk']), "t0": (vals['t0']), "t1": (vals['t1']), "dt": (vals['dt']), }, debug=self.parseBoolean(vals['debug'])) except: e = sys.exc_info()[0] print('---- Failed to invoke algorithm', e) return False return True if __name__ == '__main__': import bis_commandline sys.exit(bis_commandline.loadParse(cropImage(), sys.argv, False))