8000 dose fixes by Vilax · Pull Request #152 · I2PC/scipion-em-xmipptomo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dose fixes #152

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

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions xmipptomo/protocols/protocol_extract_particlestacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def _defineParams(self, form):
label='Box size',
help='The particle stack are extracted as squares. The box size defines the edge of the square',
important=True)

#TODO: This flag can be automitized
#form.addParam('defocusDir', BooleanParam,
# label='Defocus increase with z positive?', default=True,
# help='This flag must be put if the defocus increases or decreases along the z-axis. This is requires'
# 'to set the local CTF.')

form.addParam('invertContrast', BooleanParam,
label='Invert Contrast', default=True,
Expand Down Expand Up @@ -213,7 +219,8 @@ def writeMdTiltSeriesWithCTF(self, ts, tomoPath):
warningStr = ''
mdts = lib.MetaData()
for idxTS, idxCTF in zip(sorted_Idx_doseValueInTS, sorted_doseValueInCTF):
if doseValueInTS[idxTS] != doseValueInTSCTF[idxCTF]:
dose = doseValueInTS[idxTS]
if dose != doseValueInTSCTF[idxCTF]:
warningStr += '%s \n' % tsId
break
else:
Expand Down Expand Up @@ -245,6 +252,7 @@ def writeMdTiltSeriesWithCTF(self, ts, tomoPath):
nRow.setValue(lib.MDL_ANGLE_ROT, rot)
nRow.setValue(lib.MDL_SHIFT_X, Sx)
nRow.setValue(lib.MDL_SHIFT_Y, Sy)
nRow.setValue(lib.MDL_DOSE, dose)
nRow.addToMd(mdts)

fnts = os.path.join(tomoPath, "%s_ts.xmd" % tsId)
Expand Down Expand Up @@ -282,6 +290,8 @@ def extractStackStep(self, objId):
params += ' --coordinates %s' % fnCoords
params += ' --boxsize %i' % self.boxSize.get()
params += ' --sampling %f' % ts.getFirstItem().getSamplingRate()
#if self.defocusDir.get():
# params += ' --defocusPositive '
if self.setCTFinfo:
params += ' --setCTF '
if self.invertContrast.get():
Expand All @@ -304,6 +314,7 @@ def createOutputStep(self):
ts = self.tiltseries.get()
firstItem = ts.getFirstItem()
acquisitonInfo = firstItem.getAcquisition()
print(acquisitonInfo)
# TODO: Check the sampling if the tomograms are different than the picked ones
# TODO: Check the sampling rate if a downsampling option is implemented
outputSet = None
Expand All @@ -313,7 +324,7 @@ def createOutputStep(self):
bs = self.boxSize.get()
self.outputParticleStackSet.setDim(ImageDim(bs, bs, bs))
self.outputParticleStackSet.setAnglesCount(ts.getAnglesCount())
if firstItem.getAcquisition():
if acquisitonInfo:
acquisition = TomoAcquisition()
acquisition.setAngleMin(acquisitonInfo.getAngleMin())
acquisition.setAngleMax(acquisitonInfo.getAngleMax())
Expand All @@ -336,9 +347,12 @@ def createOutputStep(self):
if self.asSPAparticles:
fn = self._getExtraPath('allparticles.xmd')
outputSet = self._createSetOfParticles()
outputSet.setAcquisition(acquisitonInfo)
self.createMdWithall2DTiltParticles(fn)
#TODO set dose per particle
readSetOfParticles(fn, outputSet)
outputSet.setSamplingRate(self.tiltseries.get().getSamplingRate())
outputSet.write()

self._defineOutputs(outputParticles=outputSet)
self._defineSourceRelation(self.coords, outputSet)
Expand Down Expand Up @@ -366,6 +380,7 @@ def createMdWithall2DTiltParticles(self, fn):
rot = row.getValue(lib.MDL_ANGLE_ROT)
Sx = row.getValue(lib.MDL_SHIFT_X)
Sy = row.getValue(lib.MDL_SHIFT_Y)
dose = row.getValue(lib.MDL_DOSE)

rowglobal.setValue(md.MDL_IMAGE, fnImg[0] + '@' + os.path.join(basemdpath, fnImg[1]))
rowglobal.setValue(md.MDL_TSID, ts_orig)
Expand All @@ -377,6 +392,7 @@ def createMdWithall2DTiltParticles(self, fn):
rowglobal.setValue(lib.MDL_ANGLE_PSI, psi)
rowglobal.setValue(lib.MDL_SHIFT_X, Sx)
rowglobal.setValue(lib.MDL_SHIFT_Y, Sy)
rowglobal.setValue(lib.MDL_DOSE, dose)
rowglobal.addToMd(mdAllParticles)
mdAllParticles.write(fn)

Expand Down
0