Skip to content

Commit

Permalink
Merge pull request #122 from scipion-em/devel
Browse files Browse the repository at this point in the history
Release 3.4.0
  • Loading branch information
Vilax authored Aug 20, 2024
2 parents 7decbdc + ec6d3a0 commit ec8f7b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v3.3.4:
Users: hotfix - solved bug in the validation method of the classic initial volume protocol.
Developers: add odd dimensions checking to the classic initial volume.
v3.3.3:
Users: hotfix - solve problems when using the emantomo viewer with coordinates picked with crYOLO.
v3.3.2:
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 '[email protected]'
# *
# **************************************************************************
__version__ = "3.3.3"
__version__ = "3.3.4"
_logo = "eman2_logo.png"
_references = ['GALAZMONTOYA2015279', 'BELL201625']
_url = "https://github.com/scipion-em/scipion-em-emantomo"
Expand Down
21 changes: 11 additions & 10 deletions emantomo/convert/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,11 @@ def jsonFilesFromSet(setScipion, path):
tomo_files = []
for file in setScipion.getFiles():
fileBasename = pwutils.removeBaseExt(file)
parentDir = basename(dirname(file))
if "__" in fileBasename:
fnInputCoor = '%s_info.json' % fileBasename.split("__")[0]
fnInputCoor = '%s-%s_info.json' % (parentDir, fileBasename.split("__")[0])
else:
fnInputCoor = '%s_info.json' % fileBasename
fnInputCoor = '%s-%s_info.json' % (parentDir, fileBasename)
pathInputCoor = pwutils.join(path, fnInputCoor)
json_files.append(pathInputCoor)
tomo_files.append(file)
Expand All @@ -389,24 +390,24 @@ def jsonFilesFromSet(setScipion, path):

def setCoords3D2Jsons(json_files, setCoords, mode="w"):
paths = []
TOMO_ID = Coordinate3D.TOMO_ID_ATTR
tomoIds = sorted(setCoords.getUniqueValues(TOMO_ID))
tomoIds = sorted(setCoords.getUniqueValues(Coordinate3D.TOMO_ID_ATTR))
json_files = sorted(json_files)
for tomoId, json_file in zip(tomoIds, json_files):
coords = []
groupIds = setCoords.getUniqueValues("_groupId", where='_tomoId="%s"' % tomoId)
dict_eman = dict(zip(groupIds, range(len(groupIds))))
for coor in setCoords.iterCoordinates():
tomoName = pwutils.removeBaseExt(coor.getVolume().getFileName())
for coord in setCoords.iterCoordinates():

tomoName = pwutils.removeBaseExt(coord.getVolume().getFileName())
if "__" in tomoName:
tomoName = '%s_info' % tomoName.split("__")[0]
else:
tomoName += "_info"
if tomoName in json_file:
coords.append([coor.getX(const.BOTTOM_LEFT_CORNER),
coor.getY(const.BOTTOM_LEFT_CORNER),
coor.getZ(const.BOTTOM_LEFT_CORNER),
"manual", 0.0, dict_eman[coor.getGroupId()]])
coords.append([coord.getX(const.BOTTOM_LEFT_CORNER),
coord.getY(const.BOTTOM_LEFT_CORNER),
coord.getZ(const.BOTTOM_LEFT_CORNER),
"manual", 0.0, dict_eman[coord.getGroupId()]])

if coords:
coordDict = {"boxes_3d": coords,
Expand Down
18 changes: 10 additions & 8 deletions emantomo/protocols/protocol_tomo_initialmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
# **************************************************************************
from enum import Enum
from emantomo.constants import INIT_MODEL_DIR, INIR_MODEL_NAME_OLD, SYMMETRY_HELP_MSG
from pwem.emlib.image import ImageHandler
from pyworkflow import BETA
from pyworkflow.protocol import params
from pyworkflow.utils.path import makePath, replaceBaseExt
from pwem.protocols import EMProtocol
Expand Down Expand Up @@ -261,17 +259,21 @@ def _validate(self):
refVol = self.reference.get()
if refVol:
# Check the dimensions
ih = ImageHandler()
x, y, z, _ = ih.getDimensions(refVol.getFileName())
refVolDims = (x, y, z)
inParticles = self.particles.get()
dimsDict = self._firstDim
dimsDict = inParticles._firstDim
inParticlesDims = (dimsDict[0], dimsDict[1], dimsDict[2])
# Eman fails if the dimensions are odd numbers
for iDim in inParticlesDims:
if iDim % 2 != 0:
errorMsg.append('The particles dimensions must be an even number')
break
x, y, z = refVol.getDimensions()
refVolDims = (x, y, z)
if refVolDims != inParticlesDims:
errorMsg.append(f'The dimensions of the reference volume {refVolDims} px and the particles '
f'{inParticlesDims} px must be the same')
# Check the sampling rate
tol = 1e-03
tol = 2e-03
inParticlesSRate = inParticles.getSamplingRate()
refVolSRate = refVol.getSamplingRate()
if abs(inParticlesSRate - refVolSRate) >= tol:
Expand All @@ -281,7 +283,7 @@ def _validate(self):
# Check the mask
mask = self.mask.get()
if mask:
x, y, z, _ = ih.getDimensions(refVol.getFileName())
x, y, z = mask.getDimensions()
maskDims = (x, y, z)
maskSRate = mask.getSamplingRate()
if inParticlesDims != maskDims:
Expand Down

0 comments on commit ec8f7b4

Please sign in to comment.