Skip to content

Commit

Permalink
Merge branch 'devel' into fi_DMD_updateModel
Browse files Browse the repository at this point in the history
  • Loading branch information
fede-pe committed Dec 11, 2023
2 parents 06bc920 + 7655d38 commit 540500c
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 24 deletions.
19 changes: 19 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## V3.23.11
- Protocols updated
- applyAlignmentTS
- extract_particlesstacks: Added angles from Tilt Series
- extract_subtomos: Keeping directions in extract subtomos
- project_subtomograms: Added angles from Tilt Series
- deep_misalignment_detection: Update deep misalignment detection with new version of subtomo extraction and fiducial size options
- subtraction_subtomo: Improved implementation with MPI and md convert
- cltomo:
- resolution_local_monotomo: Allowing odd-even associated to the full tomogram
- Protocls fixed
- extract_particlestacks: Dose fixes
- deep_misalignment_detection: Recover deleted methods
- dose_filter: Dose validation fixed
- score_coordinates:
- More xmippTomo
- Fixed calculateRotationAngleAndShiftsFromTM
- Test refactoring

## V3.23.07
- New protocols
- project_subtomograms (for obtaining sobtomogram projections)
Expand Down
2 changes: 1 addition & 1 deletion xmipptomo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

_logo = "xmipp_logo.png"
_references = ['delaRosaTrevin2013', 'Jimenez2022']
__version__ = "3.23.07.0" #X.YY.MM.sv
__version__ = "3.23.11.0" #X.YY.MM.sv
# X.Y.M = version of the xmipp release associated.
# sv = Set this to ".0" on each xmipp release.
# For not release version (hotfix) increase it --> ".1", ".2", ...
Expand Down
87 changes: 64 additions & 23 deletions xmipptomo/protocols/protocol_resolution_local_monotomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

from tomo.protocols import ProtTomoBase
from tomo.objects import Tomogram
from pyworkflow import BETA, UPDATED, NEW, PROD

MONOTOMO_METHOD_URL = 'http://github.com/I2PC/scipion/wiki/XmippProtMonoTomo'
TOMOGRAM_RESOLUTION_FILE = 'localResolutionTomogram_'
Expand All @@ -62,7 +63,7 @@ class XmippProtMonoTomo(EMProtocol, ProtTomoBase):
"""
_label = 'local Resolution MonoTomo'
_lastUpdateVersion = VERSION_2_0

_devStatus = UPDATED
def __init__(self, **args):
ProtAnalysis3D.__init__(self, **args)
self.min_res_init = Float()
Expand All @@ -72,13 +73,26 @@ def __init__(self, **args):
def _defineParams(self, form):
form.addSection(label='Input')

form.addParam('useAssociatedOddEven', BooleanParam,
default=True,
label="Are odd-even associated to the Tomograms?",
help=" .")
form.addParam('tomo', PointerParam,
pointerClass='SetOfTomograms',
condition='useAssociatedOddEven',
label='Tomograms',
important=True,
help='Set of tomograms reconstructed from the even frames of the tilt'
'series movies.')
form.addParam('oddTomograms', PointerParam, pointerClass='SetOfTomograms',
label="Odd tomogram", important=True,
condition='not useAssociatedOddEven',
help='Select the odd tomogram for determining the '
'local resolution tomogram.')

form.addParam('evenTomograms', PointerParam, pointerClass='SetOfTomograms',
label="Even Tomogram", important=True,
condition='not useAssociatedOddEven',
help='Select the even tomogram for determining the '
'local resolution tomogram.')

Expand Down Expand Up @@ -116,15 +130,22 @@ def _defineParams(self, form):
def _insertAllSteps(self):
self.min_res_init = Float(self.minRes.get())
self.max_res_init = Float(self.maxRes.get())
for tom_odd, tom_even in zip(self.oddTomograms.get(), self.evenTomograms.get()):
if tom_odd.getObjId() == tom_even.getObjId():
tomId = tom_odd.getObjId()
#self._insertFunctionStep('convertInputStep')
self._insertFunctionStep(self.resolutionMonoTomoStep, self.oddTomograms.get(), self.evenTomograms.get(), tomId)

if not self.useAssociatedOddEven.get():
for tom_odd, tom_even in zip(self.oddTomograms.get(), self.evenTomograms.get()):
if tom_odd.getObjId() == tom_even.getObjId():
tomId = tom_odd.getObjId()
# self._insertFunctionStep('convertInputStep')
self._insertFunctionStep(self.resolutionMonoTomoStep, tomId)
self._insertFunctionStep(self.createHistrogram, tomId)
else:
for tom in self.tomo.get():
tomId = tom.getObjId()
# self._insertFunctionStep('convertInputStep')
self._insertFunctionStep(self.resolutionMonoTomoStep, tomId)
self._insertFunctionStep(self.createHistrogram, tomId)
self._insertFunctionStep('createOutputStep')


def convertInputStep(self):
"""
This function takes the input tomograms and if their extension is not mrc,
Expand All @@ -137,24 +158,30 @@ def convertInputStep(self):
if (extVol2 == '.mrc') or (extVol2 == '.map'):
self.vol2Fn = self.vol2Fn + ':mrc'


def resolutionMonoTomoStep(self, oddTomos, evenTomos, tomId):
def resolutionMonoTomoStep(self, tomId):
'''
This function estimates the local resolution from the oddTomo and the evenTomo.
The output is generated in pseudo streaming. It is not a full streaming due to
the input is not updated during the execution.
'''
self.vol1Fn = oddTomos[tomId].getFileName()
self.vol2Fn = evenTomos[tomId].getFileName()

ts = self.oddTomograms.get()[tomId]
if not self.useAssociatedOddEven.get():
self.vol1Fn = self.oddTomograms.get()[tomId].getFileName()
self.vol2Fn = self.evenTomograms.get()[tomId].getFileName()
ts = self.oddTomograms.get()[tomId]

else:
ts = self.tomo.get()[tomId]
self.vol1Fn, self.vol2Fn = ts.getHalfMaps().split(',')

tsId = ts.getTsId()
sampling = ts.getSamplingRate()

#Defining the output folder
# Defining the output folder
tomoPath = self._getExtraPath(tsId)
os.mkdir(tomoPath)

#Defining outfiles
# Defining outfiles
outputlocalResTomoFn = self.createOutputPath(TOMOGRAM_RESOLUTION_FILE, tsId, MRCEXT)
fullTomogramName = self.createOutputPath(FULL_TOMOGRAM_FILE, tsId, MRCEXT)

Expand All @@ -170,7 +197,7 @@ def resolutionMonoTomoStep(self, oddTomos, evenTomos, tomId):
params += ' --meanVol %s' % fullTomogramName
if self.useMask.get():
params += ' --mask %s' % self._getFileName(BINARY_MASK)
params += ' --sampling_rate %f' % self.oddTomograms.get().getSamplingRate()
params += ' --sampling_rate %f' % sampling
params += ' --minRes %f' % self.minRes.get()
params += ' --maxRes %f' % self.maxRes.get()
params += ' --step %f' % freq_step
Expand All @@ -182,7 +209,10 @@ def resolutionMonoTomoStep(self, oddTomos, evenTomos, tomId):
outputLocalResolutionSetOfTomograms = self.getOutputLocalResolutionSetOfTomograms()

newTomogram = Tomogram()
tomo = self.oddTomograms.get()[tomId]
if not self.useAssociatedOddEven.get():
tomo = self.oddTomograms.get()[tomId]
else:
tomo = self.tomo.get()[tomId]
newTomogram.copyInfo(tomo)
newTomogram.copyAttributes(tomo, '_origin')

Expand All @@ -201,15 +231,18 @@ def createOutputPath(self, filename, tomId, ext):
the output will be tomogram_5.mrc
'''
tomoPath = self._getExtraPath(str(tomId))
fnPath = os.path.join(tomoPath, filename+str(tomId)+ext)
fnPath = os.path.join(tomoPath, filename + str(tomId) + ext)
return fnPath

def createHistrogram(self, tomId):
'''
The histogram of local resolution values of the output tomogram is computed
'''
print(tomId)
ts = self.oddTomograms.get()[tomId]

if not self.useAssociatedOddEven.get():
ts = self.oddTomograms.get()[tomId]
else:
ts = self.tomo.get()[tomId]
tsId = ts.getTsId()
fnLocRes = self.createOutputPath(TOMOGRAM_RESOLUTION_FILE, tsId, MRCEXT)
fnHist = self.createOutputPath(HISTOGRAM_RESOLUTION_FILE, tsId, XMDEXT)
Expand All @@ -225,7 +258,7 @@ def createHistrogram(self, tomId):
params += ' --mask binary_file %s' % self._getFileName(BINARY_MASK)

params += ' --steps %f' % range_res
params += ' --range %f %f' % (m, M-freq_step)
params += ' --range %f %f' % (m, M - freq_step)
params += ' -o %s' % fnHist

self.runJob('xmipp_image_histogram', params)
Expand All @@ -249,12 +282,20 @@ def getOutputLocalResolutionSetOfTomograms(self):
self.outputLocalResolutionSetOfTomograms.enableAppend()
else:
outputLocalResolutionSetOfTomograms = self._createSetOfTomograms(suffix='LocalResolution')
outputLocalResolutionSetOfTomograms.copyInfo(self.oddTomograms.get())
samplingRate = self.oddTomograms.get().getSamplingRate()
if not self.useAssociatedOddEven.get():
outputLocalResolutionSetOfTomograms.copyInfo(self.oddTomograms.get())
samplingRate = self.oddTomograms.get().getSamplingRate()
else:
outputLocalResolutionSetOfTomograms.copyInfo(self.tomo.get())
samplingRate = self.tomo.get().getSamplingRate()
outputLocalResolutionSetOfTomograms.setSamplingRate(samplingRate)
outputLocalResolutionSetOfTomograms.setStreamState(Set.STREAM_OPEN)
self._defineOutputs(outputLocalResolutionSetOfTomograms=outputLocalResolutionSetOfTomograms)
self._defineSourceRelation(self.oddTomograms, outputLocalResolutionSetOfTomograms)
if not self.useAssociatedOddEven.get():
self._defineSourceRelation(self.evenTomograms, outputLocalResolutionSetOfTomograms)
self._defineSourceRelation(self.oddTomograms, outputLocalResolutionSetOfTomograms)
else:
self._defineSourceRelation(self.tomo, outputLocalResolutionSetOfTomograms)
return self.outputLocalResolutionSetOfTomograms

def createOutputStep(self):
Expand Down
1 change: 1 addition & 0 deletions xmipptomo/tests/test_protocol_monotomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def setUpClass(cls):
def testMonoTomo(self):
MonoTomo = self.newProtocol(XmippProtMonoTomo,
objLabel='two halves monotomo',
useAssociatedOddEven=False,
oddTomograms=self.protImportHalf1.Tomograms,
evenTomograms=self.protImportHalf2.Tomograms,
useMask=False,
Expand Down

0 comments on commit 540500c

Please sign in to comment.