Skip to content

Commit

Permalink
Merge pull request #111 from scipion-em/devel
Browse files Browse the repository at this point in the history
Release 3.3.1
  • Loading branch information
pconesa authored Mar 27, 2024
2 parents fdf6a4a + 507000f commit 08197e3
Show file tree
Hide file tree
Showing 15 changed files with 525 additions and 284 deletions.
20 changes: 20 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
v3.3.1:
Users:
- Small fixes regarding the register of the tilt series acquisition attributes.
- Fix the template matching output register reported by Ricardo Righetto (thanks!).
- Fix the classic subtomo refine transformation matrices assignment when generating the output.
- Fix the particles order in the registered output of protocol extract particles from TS.
- Protocol 'extract particles from TS' is now semi-streamified.
- Protocol 'tilt series alignment and tomo reconstruction':
* Fix the sampling rate of the set of tilt series interpolated.
* Fix the generation of tomograms when not requested.
* The interpolated tilt series is now generated applying the transformation matrix in Scipion convention to the
non-interpolated tilt series.
* Input and output convert steps improved.
* Remove form parameter 'Step between tilts' as it can now be read from the acquisition.
* Add param to correct the XDrift.
* Some other changes in the protocol form.
- Protocol 'average subtomograms' adapted to work with EMAN 3D particles generated from 3D particles (the ones
resulting when using the protocol 'extract particles from TS')
Developers:
- Test for TS alignment & tomo reconstruction updated to the new TCL.
v3.3.0:
Users:
- Prevent viewers from locking the screen focus.
Expand Down
2 changes: 1 addition & 1 deletion emantomo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# * e-mail address 'scipion@cnb.csic.es'
# *
# **************************************************************************
__version__ = "3.3.0"
__version__ = "3.3.1"
_logo = "eman2_logo.png"
_references = ['GALAZMONTOYA2015279', 'BELL201625']
_url = "https://github.com/scipion-em/scipion-em-emantomo"
Expand Down
10 changes: 8 additions & 2 deletions emantomo/convert/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,18 @@ def jsons2SetCoords3D(protocol, setTomograms, outPath):
coord3DSet.setSamplingRate(setTomograms.getSamplingRate())
first = True
for tomo in setTomograms.iterItems():
outFile = '*%s_info.json' % pwutils.removeBaseExt(tomo.getFileName().split("__")[0])
# File search by tsId
outFile = '*%s_info.json' % tomo.getTsId()
pattern = join(outPath, outFile)
files = glob.glob(pattern)

if not files or not isfile(files[0]):
continue
# File search by filename
outFile = '*%s_info.json' % pwutils.removeBaseExt(tomo.getFileName().split("__")[0])
pattern = join(outPath, outFile)
files = glob.glob(pattern)
if not files or not isfile(files[0]):
continue

jsonFnbase = files[0]
jsonBoxDict = loadJson(jsonFnbase)
Expand Down
13 changes: 13 additions & 0 deletions emantomo/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ def getProjsFrom2dStack(self, shrink=1):
(shrink * img.attrs['EMAN.ptcl_source_coord'][:-1]).tolist())
return projsList

def get3dCoordsFrom3dStack(self, scaleFactor=1, invertZ=False):
"""Generate a list of elements in which each element is a list containing the following data:
[xCoord, yCoord, zCoord] read from the HDF stack header.
"""
coordsList = []
for particleId in range(len(self._imgObjList)):
img = self._imgObjList[str(particleId)]
coords = (scaleFactor * img.attrs['EMAN.ptcl_source_coord']).tolist()
if invertZ:
coords[-1] = -1 * coords[-1]
coordsList.append(coords)
return coordsList

def getSamplingRate(self):
"""Reads the sampling rate from the HDF header"""
return self._imgObjList['0'].attrs['EMAN.apix_x']
Expand Down
13 changes: 10 additions & 3 deletions emantomo/protocols/protocol_average_subtomos.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@
import glob
import os
import shutil
from os.path import join, basename
from os.path import join, basename, abspath

from pyworkflow import BETA

from pwem.protocols import EMProtocol
from pyworkflow.protocol import PointerParam, FloatParam, StringParam, BooleanParam, LEVEL_ADVANCED
from pyworkflow.utils import Message, makePath, removeBaseExt, replaceExt
from pyworkflow.utils import Message, makePath, removeBaseExt, replaceExt, createLink
from ..constants import SPT_00_DIR, INPUT_PTCLS_LST, THREED_01, SYMMETRY_HELP_MSG, SUBTOMOGRAMS_DIR

from ..convert import writeSetOfSubTomograms, refinement2Json
import emantomo

from tomo.protocols import ProtTomoBase
from tomo.objects import AverageSubTomogram
from ..objects import EmanParticle, EmanSetOfParticles


class OutputsAverageSubtomos(enum.Enum):
Expand Down Expand Up @@ -118,7 +119,13 @@ def _initialize(self):

def convertInputStep(self):
inSubtomos = self.inputSetOfSubTomogram.get()
writeSetOfSubTomograms(inSubtomos, self.hdfSubtomosDir)
if type(inSubtomos) is EmanSetOfParticles:
# If True, the 3D particles HDF stacks will already exist because they have been extracted with EMAN pppt
hdfStacks = inSubtomos.getUniqueValues(EmanParticle.STACK_3D_HDF)
[createLink(abspath(hdfStack), self._getExtraPath(SUBTOMOGRAMS_DIR, basename(hdfStack))) for
hdfStack in hdfStacks]
else:
writeSetOfSubTomograms(inSubtomos, self.hdfSubtomosDir)
refinement2Json(self, inSubtomos)

# Generate a virtual stack of particle represented by a .lst file, as expected by EMAN
Expand Down
8 changes: 5 additions & 3 deletions emantomo/protocols/protocol_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# *
# **************************************************************************
import glob
import logging
import re
from os.path import join, abspath, basename

Expand All @@ -44,6 +45,9 @@
from tomo.protocols import ProtTomoBase
from tomo.utils import getNonInterpolatedTsFromRelations


logger = logging.getLogger(__name__)

IN_TS = 'inputTS'
IN_COORDS = 'inputCoordinates'
IN_CTF = 'inputCTF'
Expand All @@ -70,9 +74,7 @@ def convertTsStep(self, mdObj):
# The converted TS must be unbinned, because EMAN will read the sampling rate from its header. This is why
# the TS associated to the CTF is the one considered first. Later, when generating the json, the TS alignment
# parameters are read from the introduced TS and the shifts are scaled to at the unbinned scale
# if mdObj.ctf:
# inTsFName = mdObj.ctf.getTiltSeries().getFirstItem().getFileName()
# else:
logger.info(f'Converting TS {mdObj.tsId} into HDF...')
inTsFName = mdObj.ts.getFirstItem().getFileName()
sRate = mdObj.ts.getSamplingRate()
self.convertOrLink(inTsFName, mdObj.tsId, TS_DIR, sRate)
Expand Down
4 changes: 2 additions & 2 deletions emantomo/protocols/protocol_clip_tomograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _defineParams(self, form):
label="Input tomograms",
important=True)

line = form.addLine('New center coordinates [pix.] (opt.)',
line = form.addLine('New center coordinates [px] (opt.)',
help='For each empty coordinate, the correspònding original center coordinate '
'will be used.')
line.addParam('xc', IntParam,
Expand All @@ -75,7 +75,7 @@ def _defineParams(self, form):
label="cz",
allowsNull=True)

line = form.addLine('New dimensions [pix.] (opt.)',
line = form.addLine('New dimensions [px] (opt.)',
help='For each empty dimension, the original corresponding dimension will be used.')
line.addParam('xDim', IntParam,
label="dx",
Expand Down
Loading

0 comments on commit 08197e3

Please sign in to comment.