Skip to content

Commit

Permalink
Merge pull request #90 from scipion-em/devel
Browse files Browse the repository at this point in the history
3.9.1
  • Loading branch information
azazellochg committed May 15, 2024
2 parents 3727f38 + 01234f7 commit 660c0e0
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.9.1
Users:
- Adding a main help to the protocols and some helps modified.
- Phase shift parameter are now in a line
3.9:
Users:
- add ctffind5, rename config vars
Expand Down
2 changes: 1 addition & 1 deletion cistem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .constants import *


__version__ = '3.9'
__version__ = '3.9.1'
_logo = "cistem_logo.png"
_references = ['Grant2018']

Expand Down
41 changes: 21 additions & 20 deletions cistem/protocols/program_ctffind.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ def defineProcessParams(cls, form):
line = group.addLine('Defocus search range (A)',
condition='not recalculate',
help='Select _minimum_ and _maximum_ values for '
'defocus search range (in A). Underfocus'
' is represented by a positive number.')
'defocus search range (in A). Underfocus '
'is represented by a positive number. This '
'range is critical for the proper estimation. '
'Note that these number should be around the '
'nominal defocus of the acquisition.')
line.addParam('minDefocus', params.FloatParam, default=5000.,
label='Min')
line.addParam('maxDefocus', params.FloatParam, default=50000.,
Expand Down Expand Up @@ -158,24 +161,22 @@ def defineProcessParams(cls, form):
'with variable phase shift that must be '
'determined together with the defocus '
'parameters?')
form.addParam('minPhaseShift', params.FloatParam, default=0.,
label="Minimum phase shift (deg)",
condition='findPhaseShift',
help='If finding an additional phase shift, '
'this value sets the lower bound for the '
'search.')
form.addParam('maxPhaseShift', params.FloatParam, default=180,
label="Maximum phase shift (deg)",
condition='findPhaseShift',
help='If finding an additional phase shift, '
'this value sets the upper bound for the '
'search.')
form.addParam('stepPhaseShift', params.FloatParam, default=10,
label="Phase shift search step (deg)",
condition='findPhaseShift',
help='If finding an additional phase shift, '
'this value sets the step size for the '
'search.')
line = form.addLine('Phase shift (deg)',
condition='findPhaseShift',
help="Select _minimum_ and _maximum_ values for "
" phase shift search range (in deg). Also "
"the search step should be provided. "
"The phase shift will be estimated in step from the "
"minumum to the maximum pprovided values")
line.addParam('minPhaseShift', params.FloatParam, default=0.,
label="Min",
condition='findPhaseShift')
line.addParam('maxPhaseShift', params.FloatParam, default=180.,
label="Max",
condition='findPhaseShift')
line.addParam('stepPhaseShift', params.FloatParam, default=10.,
label="Step",
condition='findPhaseShift')

form.addParallelSection(threads=3)

Expand Down
4 changes: 2 additions & 2 deletions cistem/protocols/protocol_ctffind.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def _getErrorFromCtffindTxt(self, mic, e):
file = self._getCtfOutPath(mic)
with open(file, "r") as fh:
for line in fh.readlines():
if line.startswith("Error"):
return line.replace("Error:", "")
if "Error:" in line:
return line.split("Error:")[-1]
return e

def _estimateCTF(self, mic, *args):
Expand Down
3 changes: 2 additions & 1 deletion cistem/protocols/protocol_tomo_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@

class CistemProtTomoResample(EMProtocol, ProtTomoBase):
"""
Resample tomograms by Fourier cropping/padding using cisTEM. This is equivalent to binning/unbinning operations but free of aliasing artifacts.
Resample tomograms by Fourier cropping/padding using cisTEM.
This is equivalent to binning/unbinning operations but free of aliasing artifacts.
More info:
https://cistem.org
Expand Down
47 changes: 37 additions & 10 deletions cistem/protocols/protocol_ts_ctffind.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,39 @@

MRCS_EXT = ".mrcs"
# create simple, lightweight data structures similar to a class, but without the overhead of defining a full class
CistemTsCtfMd = namedtuple('CistemTsCtfMd', ['ts', 'tsFn', 'outputLog', 'outputPsd'])
CistemTsCtfMd = namedtuple('CistemTsCtfMd',
['ts', 'tsFn', 'outputLog', 'outputPsd'])


class TsCtffindOutputs(Enum):
CTFs = SetOfCTFTomoSeries


class CistemProtTsCtffind(EMProtocol):
""" CTF estimation on a set of tilt series using CTFFIND. """
""" The contrast transfer function (CTF) affects the relative signal-to-noise
ratio (SNR) of Fourier components of each image. Those Fourier components
where the CTF is near 0.0 have very low SNR compared to others. It is therefore
essential to obtain accurate estimates of the CTF for each image so that
data from multiple imges may be combined in an optimal manner during later
processing.\n
You can use CTFfind (Rohou & Grigorieff, 2015) to estimate CTF parameter values
for each image. The main parameter to be determined for each image is the
objective lens defocus (in Angstroms). Because in general lenses are astigmatic,
one actually needs to determine two defocus values (describing defocus along
the lens' major and minor axes) and the angle of astigmatism.\n
To estimate the values of these three defocus parameters for an image,
CTFfind computes a filtered version of the amplitude spectrum of the micrograph
and then fits a model of the CTF (Equation 6 of Rohou & Grigorieff) to this
filtered amplitude spectrum. It then returns the values of the defocus parameters
which maximize the quality of the fit, as well as an image of the filtered
amplitude spectrum, with the CTF model.\n
Another diagnostic output is a 1D plot of the experimental amplitude spectrum,
the CTF fit and the quality of fitting.
"""

_label = 'tilt-series ctffind'
_devStatus = PROD
_possibleOutputs = TsCtffindOutputs
Expand All @@ -72,7 +96,7 @@ def _defineParams(self, form, stream=False):
form.addSection(label='Input')
form.addParam('inputTiltSeries', params.PointerParam, important=True,
pointerClass='SetOfTiltSeries, SetOfCTFTomoSeries',
label='Input tilt series')
label='Tilt series')
form.addHidden('recalculate', params.BooleanParam,
default=False,
condition='recalculate',
Expand All @@ -94,15 +118,19 @@ def _insertAllSteps(self):
self._initialize()
pIdList = []
for mdObj in self.tsCtfMdList:
pidConvert = self._insertFunctionStep(self.convertInputStep, mdObj, prerequisites=[])
pidProcess = self._insertFunctionStep(self.processTiltSeriesStep, mdObj, prerequisites=pidConvert)
pidCreateOutput = self._insertFunctionStep(self.createOutputStep, mdObj, prerequisites=pidProcess)
pidConvert = self._insertFunctionStep(self.convertInputStep,
mdObj, prerequisites=[])
pidProcess = self._insertFunctionStep(self.processTiltSeriesStep,
mdObj, prerequisites=pidConvert)
pidCreateOutput = self._insertFunctionStep(self.createOutputStep,
mdObj, prerequisites=pidProcess)
pIdList.append(pidCreateOutput)
self._insertFunctionStep(self.closeStep, prerequisites=pIdList)

def _initialize(self):
self.inTsSet = self._getInputTs()
self._params = createCtfParams(self.inTsSet, self.windowSize.get(), self.lowRes.get(), self.highRes.get(),
self._params = createCtfParams(self.inTsSet, self.windowSize.get(),
self.lowRes.get(), self.highRes.get(),
self.minDefocus.get(), self.maxDefocus.get())
self._ctfProgram = ProgramCtffind(self)
for ts in self.inTsSet.iterItems():
Expand Down Expand Up @@ -143,7 +171,8 @@ def createOutputStep(self, mdObj):
if outCtfSet:
outCtfSet.enableAppend()
else:
outCtfSet = SetOfCTFTomoSeries.create(self._getPath(), template='ctfTomoSeriess%s.sqlite')
outCtfSet = SetOfCTFTomoSeries.create(self._getPath(),
template='ctfTomoSeriess%s.sqlite')
outCtfSet.setSetOfTiltSeries(self.inTsSet)
outCtfSet.setStreamState(Set.STREAM_OPEN)
self._defineOutputs(**{self._possibleOutputs.CTFs.name: outCtfSet})
Expand Down Expand Up @@ -221,5 +250,3 @@ def getCtfParamsDict(self):
""" Return a copy of the global params dict,
to avoid overwriting values. """
return self._params


15 changes: 8 additions & 7 deletions cistem/protocols/protocol_ts_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@

class CistemProtTsResample(EMProtocol, ProtTomoBase):
"""
Resample tilt series by Fourier cropping/padding using cisTEM. This is equivalent to binning/unbinning operations but free of aliasing artifacts.
Resample tilt series by Fourier cropping/padding using cisTEM.
This is equivalent to binning/unbinning operations but free of aliasing artifacts.
More info:
https://cistem.org
Expand Down Expand Up @@ -82,17 +83,17 @@ def _defineParams(self, form):
form.addSection(label=pwutils.Message.LABEL_INPUT)
form.addParam('inputSetOfTiltSeries', PointerParam,
pointerClass='SetOfTiltSeries',
allowsNull=False,
label='Input tilt series')
important=True,
label='Tilt series')

form.addParam('newXsize', IntParam,
default=512, validators=[Positive],
label='New X-Size',
help='Volume will be rescaled to this size in X dimension (voxels)')
label='New X-Size (px)',
help='Images will be rescaled to this size in X dimension (pixels)')
form.addParam('newYsize', IntParam,
default=512, validators=[Positive],
label='New Y-Size',
help='Volume will be rescaled to this size in Y dimension (voxels)')
label='New Y-Size (px)',
help='Images will be rescaled to this size in Y dimension (pixels)')

# -------------------------- INSERT steps functions -----------------------
def _insertAllSteps(self):
Expand Down
2 changes: 1 addition & 1 deletion cistem/wizards.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _getProvider(self, protocol):
_objs = self._getParameters(protocol)['input']
return CtfWizard._getListProvider(self, _objs)

def show(self, form):
def show(self, form, *args):
protocol = form.protocol
params = self._getParameters(protocol)
_value = params['value']
Expand Down

0 comments on commit 660c0e0

Please sign in to comment.