-
Notifications
You must be signed in to change notification settings - Fork 0
Fi feature detect misalignment #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fede-pe
wants to merge
178
commits into
devel
Choose a base branch
from
fi_feature_detectMisalignment
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
178 commits
Select commit
Hold shift + click to select a range
fc5cef8
first commit, new protocol to detect misalignment
fede-pe 6bade50
add protocol to init
fede-pe c1a925f
add to protocols conf
fede-pe 3866d99
first form draft finished
fede-pe 8c930fe
new method to write xmipp tilt angle file from ts
fede-pe 80662ae
convert input step
fede-pe ca85a2f
execute command
fede-pe e3d5a9a
new method to read metadata files
fede-pe 74a492b
read enable info
fede-pe 3770fa4
add default values
fede-pe 15dd8e4
change fid size to nm
fede-pe ea545df
fixes
fede-pe b5741fd
method to read coordinates files
fede-pe 964b774
enhance readXmippMetadataEnabledTiltImages performance
fede-pe 5107482
fixes noww working
fede-pe f75315d
generate outputset of tilt series
fede-pe ae92732
update output paths
fede-pe fc82f00
fixes in xmd tilt angle file generation
fede-pe d6ef067
adapt protocol to new file parsing
fede-pe 37a5a6f
add detect misalignment
fede-pe 8a6fd99
generate alignment report dictionary
fede-pe 8157143
summaty completed with report
fede-pe 659b045
fixes in summary, everything OK
fede-pe d9d74eb
remove debug code
fede-pe 8f4c609
update form with new params
fede-pe 6b40336
change default value
fede-pe 01517a7
parellize protocol
fede-pe a767376
add try catch debug
fede-pe 592aa45
remove if statement debug
fede-pe 2dd6266
remove if statement debug
fede-pe 97fb779
remove if statement debug III
fede-pe 615ff15
remove if statement debug IV
fede-pe e6a22d0
remove if statement debug V
fede-pe 16602ed
remove if statement debug VI
fede-pe 8682e85
remove if statement debug VI
fede-pe d9bcbed
remove if statement debug VII
fede-pe 82609d1
fixing sets I
fede-pe a895b4b
fixes pablo I
fede-pe f49760d
fixes pablo II
fede-pe 2501dfe
fixes pablo III
fede-pe 0b7894b
rename
fede-pe ba57f71
new method to generate xmd files from coordinates
fede-pe aed26d0
generate coordinates xmd file
fede-pe 1b90f8e
update command to new parameters
fede-pe f08e70a
update requirements (statsmodels and dependecies)
fede-pe 1098899
new mehots to generate residual statistical information table from xm…
fede-pe 6d8183b
generating ouptut as string in progress. END OF SESSION
fede-pe dbc07ce
fixes, end of session
fede-pe fa024c6
fixes + report info in summary
fede-pe fe2e716
merge with devel
fede-pe 0f39bee
fixes in protocols conf after merging
fede-pe 93ecf7b
use check for missing cooridnates
fede-pe 6be894d
add method to utils to calculate rotation angle from transformation m…
fede-pe 5fd5db0
use swapxy logic in apply transformation matrices in ts
fede-pe 77ae449
refactor
fede-pe ca49793
fixes in converti input step interpolation
fede-pe d9af3f5
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe 27c5fb0
return avg rotation angle as 0 when ti has no trasnform·
fede-pe 57a0dee
new method to generate xmd with tilt series 3d coordiantes
fede-pe 239bbe6
adapt protocol to new tilt series 3d coordinates object
fede-pe dd77b84
use dimentions from sot of soc
fede-pe 76634c6
test in herts-dos
fede-pe 24c7999
correct dimensions for coordinates
fede-pe 34a8dd4
merge devel
fede-pe 14c449b
fixes from merging with devel I
fede-pe 22ea983
changes due to fixes in tilt sereis coordinates object
fede-pe cd187c1
fixes in summary
fede-pe 4344d77
add param to threshold distance coord projection-fiducial detected
fede-pe 7d33002
merge devel, solve conflicts
fede-pe 991bb6e
method to read residual info from xmd file
fede-pe d329caf
split LM in ali and misali
fede-pe d13484f
close lm sets
fede-pe 6c25a6d
generate output set of landmark models
fede-pe 2de0b7e
fixes
fede-pe 42577e7
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe 829693a
comment deprecated code, raises error with new xmipp program version
fede-pe 20f4e34
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe ddc24f8
make avgResidPercentile_LocalAlignment param
fede-pe c77fffc
remove debug code
fede-pe a4a32d4
fix in getOutputSetOfAlignedLandmarkModels
fede-pe 1e9553c
fixes in getOutputSetOfMisalignedTiltSeries and getOutputSetOfAligned…
fede-pe 2d5bd2b
fixes in getOutputSetOfMisalignedTiltSeries and getOutputSetOfAligned…
fede-pe d31baab
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe a9bfe8a
update default params·
fede-pe c5f8873
merge with devel
fede-pe 39a00eb
fixes in output .sfid generation
fede-pe 89e1791
create protocol
fede-pe f15f41a
first protocol scratch
fede-pe 9b95dda
add to init
fede-pe 4c768eb
add to portocols confW
fede-pe 02e7449
convert input step
fede-pe 30e988b
compose xmipp comand step
fede-pe 25e9271
add create output step
fede-pe 6caf583
fix class name
fede-pe 957036f
create method to parse lm file
fede-pe 7b7a121
close outptu step
fede-pe 59a8d6a
fixes I
fede-pe 4f2313d
fixes II
fede-pe b3863e1
remove debug code
fede-pe dd1e78f
merge with detect_landmarks
fede-pe 6a5df4d
merge with devel, solve conflicts
fede-pe 2fbc8d9
fix otuput landmark model generation
fede-pe 82c1995
adapt variables and command composition to new xmipp program
fede-pe 8d508a0
set applyTSTransformation as True in outputLM
fede-pe 3a42834
comment removed avgResidPercentile_LocalAlignment program param
fede-pe 1eb1c3e
remove unused params
fede-pe 47972df
new protocol version using splitted programs
fede-pe dd021e2
first structure accepting SoLM as input
fede-pe 6469ea2
allow isots or isolm as input
fede-pe c6310ba
new method to generate res mod info file
fede-pe dd5ad6d
fixes in setoflandmark models mode
fede-pe 002de92
remove unused imports
fede-pe b35f208
fixes when input us a SOLM
fede-pe f6411e8
remove debug code
fede-pe e215864
fixes in validate
fede-pe 0e78b20
fixes in vResMod file generation
fede-pe f7e804f
check for residuals with modeule equal zero
fede-pe fb4fc4a
mege with devel. Resolve conflicts·
fede-pe fbcd862
fix in util method for alingment report reading
fede-pe ac949bc
fix introduces typo
fede-pe 8028973
fix filenames vResMod
fede-pe 512d212
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe c5ac92e
Merge branch 'devel' into fi_feature_detectMisalignment
fede-pe 473eff9
refactor, update hertz-dos
fede-pe 0ba9e22
iterate over lm model is used as input to avoid non complete sets2
fede-pe bd000e4
set image threshold for local misalignment
fede-pe a33f39f
RESOLVE CONFLICTS
fede-pe 1832c99
commit to start new process
fede-pe 686e8f5
integrate xmipp_tomo_tiltseries_detect_misalignment_corr in protocol …
fede-pe 7c8daff
add todo + fix typo
fede-pe 71e193b
add parallel section to detect msiali
fede-pe c220da4
generate tilt angle file always
fede-pe 6f39f56
fixes in tilt series coordinates
fede-pe 120bd3c
add subtleMisaliToggle
fede-pe 1f87565
trigger subtle misalignment only if ts aligned
fede-pe d315b1b
remove TODO comments
fede-pe 8be7ab3
improve help form
fede-pe f33b1c7
new form to consider ts coming from lm
fede-pe 4843373
new logic of tilt-seris + improve form help
fede-pe 5743298
allow null in form
fede-pe 64bf6da
change structure, now no input ts is needed to detect misali from res…
fede-pe 27b16f6
add condition to check if Lm do not brin gresidual informatioN
fede-pe 1b2c2b6
use NaN form residual info
fede-pe 6df1e42
do not analyze landmark with no residual info
fede-pe 1483687
new parameter with number of tilt images
fede-pe 025d681
remove residual outliers as option
fede-pe d96aa22
add numberFTdirOfDirections option
fede-pe 3b8faad
fix from previos commit
fede-pe c492cab
add votting criteria
fede-pe f6337ac
fix form
fede-pe 6840665
solve conflics
fede-pe 5a9fbdc
merge devel
fede-pe 35b822b
merge with detect lm ts
fede-pe 48d0a97
remove deprecated protocols from init
fede-pe bd85dce
rename protocl to covnention
fede-pe 981babd
update init with detect landmark in ts
fede-pe f68a000
add FT directions to params in detect LM
fede-pe 90c5257
add FT directions to params in detect LM
fede-pe 8ee2208
remove unused params from protocol
fede-pe 86bc2c0
update output generation in landmark detection
fede-pe 47f0675
fix output generatioN
fede-pe aa264bf
save fid size in angstroms
fede-pe 92d3edb
update default params
fede-pe 185adbb
update default params
fede-pe 2031590
remove subtle misalignemnt form protocol
fede-pe c577eee
add paramthrRatioMahalanobis to program
fede-pe ec8f526
update builPlugin.yml
fede-pe 8d9f647
update builPlugin.yml II
fede-pe 3f95ca0
update builPlugin.yml III
fede-pe dcdfe4f
update builPlugin.yml IV
fede-pe e65f002
PR fixes I: remove rotate astigmatism from protocols.conf
fede-pe 3711913
PR fixes II: update help
fede-pe f889365
PR fixes III: do not generate output if no landmark is detected in TS
fede-pe 5f96b85
PR fixes IV: remove commented code
fede-pe 5ab3530
PR fixes V: use metadata to write coordinates file
fede-pe 6230b24
Fix: remove unused import
fede-pe b064b0b
PR fixes VI: e
fede-pe c040a2c
Added workflow dispatch trigger to the build action
oierlauzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ scipion-em-xmipp | |
scipion-em-tomo | ||
scipion-em >= 3.0.8 | ||
scipion-em-xmippBase | ||
pandas <= 1.3.5 | ||
statsmodels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
# ************************************************************************** | ||
# * | ||
# * Authors: Federico P. de Isidro Gomez (fp.deisidro@cnb.csi.es) [1] | ||
# * | ||
# * [1] Centro Nacional de Biotecnologia, CSIC, Spain | ||
# * | ||
# * This program is free software; you can redistribute it and/or modify | ||
# * it under the terms of the GNU General Public License as published by | ||
# * the Free Software Foundation; either version 2 of the License, or | ||
# * (at your option) any later version. | ||
# * | ||
# * This program is distributed in the hope that it will be useful, | ||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# * GNU General Public License for more details. | ||
# * | ||
# * You should have received a copy of the GNU General Public License | ||
# * along with this program; if not, write to the Free Software | ||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
# * 02111-1307 USA | ||
# * | ||
# * All comments concerning this program package may be sent to the | ||
# * e-mail address 'scipion@cnb.csic.es' | ||
# * | ||
# ************************************************************************** | ||
|
||
import os | ||
from pyworkflow import BETA | ||
import pyworkflow.protocol.params as params | ||
import pyworkflow.utils.path as path | ||
from pyworkflow.object import Set, Boolean | ||
from pyworkflow.protocol.constants import STEPS_PARALLEL | ||
from pwem.protocols import EMProtocol | ||
import tomo.objects as tomoObj | ||
from tomo.protocols import ProtTomoBase | ||
import xmipptomo.utils as utils | ||
|
||
|
||
OUTPUT_COORDS_FILENAME = "outputLandmarkCoordinates.xmd" | ||
|
||
|
||
class XmippProtDetectLandmarkTS(EMProtocol, ProtTomoBase): | ||
""" | ||
Scipion protocol for xmipp_tomo_detect_landmarks. This protocol detect fiducial landmarks in a tilt series. It will | ||
not produce a correspondence of landmark between images so chains will not be constructed only single landmark per | ||
tilt image. | ||
""" | ||
|
||
_label = 'detect landmarks TS' | ||
_devStatus = BETA | ||
|
||
def __init__(self, **kwargs): | ||
EMProtocol.__init__(self, **kwargs) | ||
ProtTomoBase.__init__(self) | ||
self.stepsExecutionMode = STEPS_PARALLEL | ||
|
||
# -------------------------- DEFINE param functions ----------------------- | ||
def _defineParams(self, form): | ||
form.addSection('Input') | ||
|
||
form.addParam('inputSetOfTiltSeries', | ||
params.PointerParam, | ||
pointerClass='SetOfTiltSeries', | ||
important=True, | ||
label='Input set of tilt-series') | ||
|
||
form.addParam('fiducialSize', | ||
params.FloatParam, | ||
important=True, | ||
label='Landmark size (nm)', | ||
help='Landmark size in nanometers (nm).') | ||
|
||
# Advanced params | ||
form.addParam('thrSD', | ||
params.FloatParam, | ||
expertLevel=params.LEVEL_ADVANCED, | ||
default=5, | ||
label='Coordinate value SD threshold', | ||
help='Number of SD a coordinate value must be over the mean to consider that it belongs to a ' | ||
'high contrast feature.') | ||
|
||
form.addParam('targetLMsize', | ||
params.FloatParam, | ||
expertLevel=params.LEVEL_ADVANCED, | ||
default=8, | ||
label='Target landmark size (px)', | ||
help='Target landmark size to adjust down sampling before filtering. Default value is 8 px.') | ||
|
||
form.addParam('numberFTdirOfDirections', | ||
params.IntParam, | ||
expertLevel=params.LEVEL_ADVANCED, | ||
default=16, | ||
label='Fourier filter directions', | ||
help='Number of directions to analyze in the Fourier directional filter.') | ||
|
||
# -------------------------- INSERT steps functions --------------------- | ||
def _insertAllSteps(self): | ||
allcosId = [] | ||
|
||
for ts in self.inputSetOfTiltSeries.get(): | ||
tsObjId = ts.getObjId() | ||
cisID = self._insertFunctionStep(self.convertInputStep, | ||
tsObjId, | ||
prerequisites=[]) | ||
dlsID = self._insertFunctionStep(self.detectLandmarksStep, | ||
tsObjId, | ||
prerequisites=[cisID]) | ||
cosID = self._insertFunctionStep(self.createOutputStep, | ||
tsObjId, | ||
prerequisites=[dlsID]) | ||
allcosId.append(cosID) | ||
|
||
self._insertFunctionStep(self.closeOutputSetsStep, | ||
prerequisites=allcosId) | ||
|
||
# --------------------------- STEPS functions ---------------------------- | ||
def convertInputStep(self, tsObjId): | ||
ts = self.inputSetOfTiltSeries.get()[tsObjId] | ||
tsId = ts.getTsId() | ||
|
||
extraPrefix = self._getExtraPath(tsId) | ||
tmpPrefix = self._getTmpPath(tsId) | ||
|
||
path.makePath(tmpPrefix) | ||
path.makePath(extraPrefix) | ||
|
||
firstItem = ts.getFirstItem() | ||
|
||
"""Apply the transformation form the input tilt-series""" | ||
# Use Xmipp interpolation via Scipion | ||
if firstItem.hasTransform(): | ||
avgRotAngle = utils.calculateAverageRotationAngleFromTM(ts) | ||
swap = True if (avgRotAngle > 45 or avgRotAngle < -45) else False | ||
|
||
outputTsFileName = os.path.join(tmpPrefix, firstItem.parseFileName()) | ||
ts.applyTransform(outputTsFileName, swapXY=swap) | ||
|
||
else: | ||
outputTsFileName = os.path.join(tmpPrefix, firstItem.parseFileName()) | ||
ts.applyTransform(outputTsFileName) | ||
|
||
def detectLandmarksStep(self, tsObjId): | ||
ts = self.inputSetOfTiltSeries.get()[tsObjId] | ||
tsId = ts.getTsId() | ||
|
||
extraPrefix = self._getExtraPath(tsId) | ||
tmpPrefix = self._getTmpPath(tsId) | ||
|
||
firstItem = ts.getFirstItem() | ||
|
||
params = { | ||
'i': os.path.join(tmpPrefix, firstItem.parseFileName() + ":mrcs"), | ||
'o': os.path.join(extraPrefix, OUTPUT_COORDS_FILENAME), | ||
'thrSD': self.thrSD.get(), | ||
'samplingRate': self.inputSetOfTiltSeries.get().getSamplingRate(), | ||
'fiducialSize': self.fiducialSize.get() * 10, | ||
'targetLMsize': self.targetLMsize.get(), | ||
'numberFTdirOfDirections': self.numberFTdirOfDirections.get() | ||
} | ||
|
||
args = "-i %(i)s " \ | ||
"-o %(o)s " \ | ||
"--thrSD %(thrSD).2f " \ | ||
"--samplingRate %(samplingRate).2f " \ | ||
"--fiducialSize %(fiducialSize).2f " \ | ||
"--targetLMsize %(targetLMsize).4f " \ | ||
"--numberFTdirOfDirections %(numberFTdirOfDirections)d " | ||
|
||
self.runJob('xmipp_tomo_detect_landmarks', args % params) | ||
|
||
def createOutputStep(self, tsObjId): | ||
Vilax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ts = self.inputSetOfTiltSeries.get()[tsObjId] | ||
tsId = ts.getTsId() | ||
|
||
extraPrefix = self._getExtraPath(tsId) | ||
|
||
firstItem = ts.getFirstItem() | ||
|
||
self.getOutputSetOfLandmarkModels() | ||
|
||
lmFileName = os.path.join(extraPrefix, firstItem.parseFileName(suffix='_lm', extension='.sfid')) | ||
lm = tomoObj.LandmarkModel(tsId=tsId, | ||
fileName=lmFileName, | ||
modelName=None, | ||
size=self.fiducialSize.get() * 10, | ||
applyTSTransformation=Boolean(False)) | ||
lm.setTiltSeries(ts) | ||
|
||
lmList = utils.parseLandmarkCoordinatesFile(os.path.join(extraPrefix, OUTPUT_COORDS_FILENAME)) | ||
|
||
if not lmList: | ||
print("WARNING: no landmark detected in tilt-series") | ||
return # Do not create output if no detected landmarks in tilt-series | ||
|
||
for i, lmInfo in enumerate(lmList): | ||
lm.addLandmark(xCoor=lmInfo[0], | ||
yCoor=lmInfo[1], | ||
tiltIm=lmInfo[2]+1, | ||
chainId=i+1, | ||
xResid=0.0, | ||
yResid=0.0) | ||
|
||
self.outputSetOfLandmarkModels.append(lm) | ||
self._store() | ||
|
||
def closeOutputSetsStep(self): | ||
if hasattr(self, "outputSetOfLandmarkModels"): | ||
self.outputSetOfLandmarkModels.setStreamState(Set.STREAM_CLOSED) | ||
self.outputSetOfLandmarkModels.write() | ||
|
||
self._store() | ||
|
||
# --------------------------- UTILS functions ---------------------------- | ||
def getOutputSetOfLandmarkModels(self): | ||
if hasattr(self, "outputSetOfLandmarkModels"): | ||
self.outputSetOfLandmarkModels.setStreamState(Set.STREAM_OPEN) | ||
self.outputSetOfLandmarkModels.enableAppend() | ||
|
||
else: | ||
outputSetOfLandmarkModels = self._createSetOfLandmarkModels() | ||
outputSetOfLandmarkModels.setSetOfTiltSeries(self.inputSetOfTiltSeries) | ||
|
||
outputSetOfLandmarkModels.copyInfo(self.inputSetOfTiltSeries.get()) | ||
|
||
outputSetOfLandmarkModels.setStreamState(Set.STREAM_OPEN) | ||
|
||
self._defineOutputs(outputSetOfLandmarkModels=outputSetOfLandmarkModels) | ||
self._defineSourceRelation(self.inputSetOfTiltSeries, outputSetOfLandmarkModels) | ||
|
||
return self.outputSetOfLandmarkModels | ||
|
||
# --------------------------- INFO functions ---------------------------- | ||
def _summary(self): | ||
summary = [] | ||
return summary | ||
|
||
def _methods(self): | ||
methods = [] | ||
|
||
return methods |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependence is on Scipion, I guess @oierlauzi
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there is no dependency on pandas in any of the required packages by this plugin. That's why this is added here.