diff --git a/CHANGES.txt b/CHANGES.txt index e74d8e73..d70188fd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,10 @@ +3.3.0: + - Fixing a bug with odd even in tomogram reconstruction + - Tolerating errors in alignment + - Making tomogram reconstruction error tolerant + - Making tilt series alignment error tolerant + - Adding possible outputs in xray eraser + - Removing visible parameters with the intepolation is not applied 3.2.0: - add more possible outputs - fixing ctf after aretomo @@ -79,4 +86,4 @@ - fix betterradius param in gold eraser tab of the fid alignment - add missing pix size in fid align - fix minpacing in gold picker - - add missing taper arg for newstack \ No newline at end of file + - add missing taper arg for newstack diff --git a/imod/protocols/protocol_base.py b/imod/protocols/protocol_base.py index 3601454c..f0d07dd9 100644 --- a/imod/protocols/protocol_base.py +++ b/imod/protocols/protocol_base.py @@ -102,7 +102,7 @@ def wrapper(self, tsId, *args): return wrapper def convertInputStep(self, tsObjId, generateAngleFile=True, - imodInterpolation=True, doSwap=False): + imodInterpolation=True, doSwap=False, oddEven=False): """ :param tsObjId: Tilt series identifier @@ -140,18 +140,30 @@ def convertInputStep(self, tsObjId, generateAngleFile=True, # Use IMOD newstack interpolation if firstItem.hasTransform(): # Generate transformation matrices file - outputTmFileName = os.path.join(tmpPrefix, - firstItem.parseFileName(extension=".xf")) + outputTmFileName = os.path.join(tmpPrefix, firstItem.parseFileName(extension=".xf")) utils.formatTransformFile(ts, outputTmFileName) - argsAlignment, paramsAlignment = self.getBasicNewstackParams(ts, + def applyNewStack(outputTsFileName, fnIn): + + argsAlignment, paramsAlignment = self.getBasicNewstackParams(ts, outputTsFileName, + inputTsFileName=fnIn, xfFile=outputTmFileName, firstItem=firstItem, doSwap=doSwap) + Plugin.runImod(self, 'newstack', argsAlignment % paramsAlignment) self.info("Interpolating tilt series %s with imod" % tsId) - Plugin.runImod(self, 'newstack', argsAlignment % paramsAlignment) + applyNewStack(outputTsFileName, None) + + if oddEven: + fnOdd = ts.getOddFileName() + fnEven = ts.getEvenFileName() + + outputOddTsFileName = os.path.join(tmpPrefix, tsId+EXT_MRCS_TS_EVEN_NAME) + outputEvenTsFileName = os.path.join(tmpPrefix, tsId+EXT_MRCS_TS_ODD_NAME) + applyNewStack(outputOddTsFileName, fnOdd) + applyNewStack(outputEvenTsFileName, fnEven) else: self.info("Linking tilt series %s" % tsId) diff --git a/imod/protocols/protocol_tomoReconstruction.py b/imod/protocols/protocol_tomoReconstruction.py index 04757213..9f1b0906 100644 --- a/imod/protocols/protocol_tomoReconstruction.py +++ b/imod/protocols/protocol_tomoReconstruction.py @@ -32,7 +32,7 @@ from tomo.objects import Tomogram from .. import Plugin -from .protocol_base import ProtImodBase, EXT_MRC_ODD_NAME, EXT_MRC_EVEN_NAME +from .protocol_base import ProtImodBase, EXT_MRC_ODD_NAME, EXT_MRC_EVEN_NAME, EXT_MRCS_TS_EVEN_NAME, EXT_MRCS_TS_ODD_NAME class ProtImodTomoReconstruction(ProtImodBase): @@ -181,7 +181,10 @@ def _insertAllSteps(self): # --------------------------- STEPS functions ----------------------------- def convertInputStep(self, tsObjId, **kwargs): # Considering swapXY is required to make tilt axis vertical - super().convertInputStep(tsObjId, doSwap=True) + oddEvenFlag = False + if self.inputSetOfTiltSeries.get().hasOddEven(): + oddEvenFlag = True + super().convertInputStep(tsObjId, doSwap=True, oddEven=oddEvenFlag) @ProtImodBase.tryExceptDecorator def computeReconstructionStep(self, tsObjId): @@ -244,13 +247,13 @@ def getArgs(): oddEvenTmp = [[], []] if self.applyToOddEven(ts): - oddFn = firstItem.getOdd().split('@')[1] + oddFn = os.path.join(tmpPrefix, tsId+EXT_MRCS_TS_ODD_NAME) paramsTilt['InputProjections'] = oddFn oddEvenTmp[0] = os.path.join(tmpPrefix, firstItem.parseFileName(extension="_odd.rec")) paramsTilt['OutputFile'] = oddEvenTmp[0] - Plugin.runImod(self, 'tilt', argsTilt % paramsTilt) - evenFn = firstItem.getEven().split('@')[1] + + evenFn = os.path.join(tmpPrefix, tsId+EXT_MRCS_TS_EVEN_NAME) paramsTilt['InputProjections'] = evenFn oddEvenTmp[1] = os.path.join(tmpPrefix, firstItem.parseFileName(extension="_even.rec")) paramsTilt['OutputFile'] = oddEvenTmp[1] diff --git a/imod/protocols/protocol_xCorrPrealignment.py b/imod/protocols/protocol_xCorrPrealignment.py index cc0bc5b0..5c29b065 100644 --- a/imod/protocols/protocol_xCorrPrealignment.py +++ b/imod/protocols/protocol_xCorrPrealignment.py @@ -47,6 +47,7 @@ class ProtImodXcorrPrealignment(ProtImodBase): _label = 'Coarse prealignment' _devStatus = BETA + _possibleOutputs = {"TiltSeries": tomoObj.SetOfTiltSeries} # -------------------------- DEFINE param functions ----------------------- def _defineParams(self, form): @@ -83,6 +84,7 @@ def _defineParams(self, form): form.addParam('binning', params.IntParam, + condition='computeAlignment==0', default=1, label='Binning for the interpolated', help='Binning to be applied to the interpolated ' @@ -91,7 +93,8 @@ def _defineParams(self, form): 'bigger than 1') form.addParam('Trimming parameters', params.LabelParam, - label='Tilt axis angle detected from import. In case another value is desired please adjust the number below') + label='Tilt axis angle detected from import. In case another value is desired please adjust the ' + 'number below') form.addParam('tiltAxisAngle', params.FloatParam, @@ -104,41 +107,40 @@ def _defineParams(self, form): 'system with no axis inversions') trimming = form.addGroup('Trimming parameters', - expertLevel=params.LEVEL_ADVANCED) + expertLevel=params.LEVEL_ADVANCED) xtrimming = trimming.addLine('Horizontal: Number of pixels to avoid from the', - expertLevel=params.LEVEL_ADVANCED, - help="Starting and ending X coordinates of a region to correlate, " - "based on the position of the region at zero tilt.") + expertLevel=params.LEVEL_ADVANCED, + help="Starting and ending X coordinates of a region to correlate, " + "based on the position of the region at zero tilt.") xtrimming.addParam('xmin', - params.IntParam, - label='left', - allowsNull=True, - expertLevel=params.LEVEL_ADVANCED) + params.IntParam, + label='left', + allowsNull=True, + expertLevel=params.LEVEL_ADVANCED) xtrimming.addParam('xmax', - params.IntParam, - label='right', - allowsNull=True, - expertLevel=params.LEVEL_ADVANCED) + params.IntParam, + label='right', + allowsNull=True, + expertLevel=params.LEVEL_ADVANCED) ytrimming = trimming.addLine('Vertical: Number of pixels to avoid from the', - expertLevel=params.LEVEL_ADVANCED, - help="Starting and ending Y coordinates of a region to correlate.") + expertLevel=params.LEVEL_ADVANCED, + help="Starting and ending Y coordinates of a region to correlate.") ytrimming.addParam('ymin', - params.IntParam, - label='top', - allowsNull=True, - expertLevel=params.LEVEL_ADVANCED) + params.IntParam, + label='top', + allowsNull=True, + expertLevel=params.LEVEL_ADVANCED) ytrimming.addParam('ymax', - params.IntParam, - label='botton', - allowsNull=True, - expertLevel=params.LEVEL_ADVANCED) - + params.IntParam, + label='botton', + allowsNull=True, + expertLevel=params.LEVEL_ADVANCED) filtering = form.addGroup('Filtering parameters', expertLevel=params.LEVEL_ADVANCED) @@ -243,8 +245,6 @@ def computeXcorrStep(self, tsObjId): 'filterRadius2': self.filterRadius2.get() } - - argsXcorr = "-input %(input)s " \ "-output %(output)s " \ "-tiltfile %(tiltfile)s " \ @@ -267,11 +267,11 @@ def computeXcorrStep(self, tsObjId): if xmin is None: xmin = 0 if xmax is None: - xmax = xdim-1 + xmax = xdim - 1 if ymin is None: ymin = 0 if ymax is None: - ymax = ydim-1 + ymax = ydim - 1 argsXcorr += " -xminmax %i,%i " % (xmin, xmax) argsXcorr += " -yminmax %i,%i " % (ymin, ymax)