--
You received this message because you are subscribed to the Google Groups "Warp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to warp-em+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/warp-em/d93522dd-5d2a-45ed-b082-b0e92a621644n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/warp-em/CAPEz%3DzqQpMHpOUsynZwZMNjVbJ5G_DoOBWbzVnm56Wg1%2B0ZuLQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/warp-em/C6B3E802-04E9-4D52-90D2-D40F23089272%40gmail.com.
On 22. Sep 2021, at 19:37, Benjamin Barad <benjami...@gmail.com> wrote:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# By Digvijay
import sys
import re
import numpy as np
import glob, os
def ConvertMDocFiles(MRCpath,mdocFileName):
os.chdir(MRCpath) # Go to the folder with the identified .mrc.mdoc file
if not os.path.exists(MRCpath+"/Adjusted"):
os.makedirs(MRCpath+"/Adjusted")
AdjustedMRCPath=MRCpath+"/Adjusted/"
ExposureTimeList=[]
CountsPerElectronList=[]
MeanIntensityList=[]
MaxIntensityList=[]
TiltAngleList=[]
with open(mdocFileName, "r") as f:
for line in f:
match1=re.search('ExposureTime = ?(\d*.\d*)',line)
match2=re.search('TiltAngle = ?(-?\d*.\d*)',line)
match5=re.search('CountsPerElectron = ?(\d*.\d*)',line)
match6=re.search('MinMaxMean = ?(\d*.\d*)\s(\d*.\d*)\s(\d*.\d*)',line)
if match2:
TiltAngleList.append(float(match2.group(1)))
if match1:
ExposureTimeList.append(float(match1.group(1)))
if match5:
CountsPerElectronList.append(float(match5.group(1)))
if match6:
MeanIntensityList.append(float(match6.group(3)))
MaxIntensityList.append(float(match6.group(2)))
f.close()
DoseRateOnCameraList=[aa/(bb*cc) for aa,bb,cc in zip(MeanIntensityList, CountsPerElectronList,ExposureTimeList)]
DoseRateAtPreTiltZero_EPS=max(DoseRateOnCameraList)
PreTiltZeroAngle= TiltAngleList[DoseRateOnCameraList.index(max(DoseRateOnCameraList))]
f.close()
input_file = open(mdocFileName, "r")
output_file = open(AdjustedMRCPath+os.path.basename(mdocFileName), "w")
for line in input_file:
match2=re.search('TiltAngle = ?(-?\d*.\d*)',line)
match3=re.search('bidir = ?(-?\d*.\d*)',line)
if match2:
NewTiltAngle=float(match2.group(1))-PreTiltZeroAngle
line = re.sub('TiltAngle = ?(-?\d*.\d*)', 'TiltAngle = '+str(NewTiltAngle), line)
if match3:
NewBiDirAngle=float(match3.group(1))-PreTiltZeroAngle
line = re.sub('bidir = ?(-?\d*.\d*)', 'bidir = '+str(NewBiDirAngle), line)
output_file.write(line)
output_file.close()
Path=os.getcwd()
for mdocFileName in glob.glob("*.mdoc"):
ConvertMDocFiles(Path,mdocFileName)
To view this discussion on the web visit https://groups.google.com/d/msgid/warp-em/5512db61-caa0-42c1-80ac-d580d79662c5n%40googlegroups.com.
On 17 Nov 2021, at 00:40, Pranav Shah <p.sha...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/warp-em/662d2ddf-d9c2-4018-bc32-a22fd6068554n%40googlegroups.com.