Skip to content

Commit

Permalink
updated startfile writing
Browse files Browse the repository at this point in the history
  • Loading branch information
MJoosten committed Sep 9, 2024
1 parent 8a8e6e0 commit abfbcae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/roodmus/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ def _extract_from_config(
for instance in molecules["instances"]:
position = instance["position"]
orientation = instance["orientation"] # rotation vector
orientation = -np.array(orientation) # invert the orientation
# convert to euler angles
# euler = geom.rot2euler(geom.expmap(np.array(orientation)))
euler = R.from_rotvec(orientation).as_euler("ZYZ")
Expand Down
41 changes: 27 additions & 14 deletions src/roodmus/simulation/write_starfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ def __init__(
"_rlnImageName",
"_rlnMicrographName",
"_rlnOpticsGroup",
"_rlnCtfMaxResolution",
"_rlnCtfFigureOfMerit",
# "_rlnCtfMaxResolution",
# "_rlnCtfFigureOfMerit",
"_rlnDefocusU",
"_rlnDefocusV",
"_rlnDefocusAngle",
Expand All @@ -405,11 +405,10 @@ def __init__(
"_rlnAngleTilt",
"_rlnOriginXAngst",
"_rlnOriginYAngst",
"_rlnNormCorrection",
"_rlnLogLikeliContribution",
"_rlnMaxValueProbDistribution",
"_rlnNrOfSignificantSamples",
"_rlnRandomSubset",
# "_rlnNormCorrection",
# "_rlnLogLikeliContribution",
# "_rlnMaxValueProbDistribution",
# "_rlnNrOfSignificantSamples",
]
self.particles = self.cif_document.add_new_block("particles")
self.loop = self.particles.init_loop(prefix="", tags=self.tags)
Expand All @@ -431,6 +430,21 @@ def parse_df(self, df_particles):
euler_phi, euler_psi, euler_theta, defocusU, defocusV, Class2D
"""

# check if the columns defocusU and defocusV are present
# if the columns are not present, but defocus is present,
# make a new column for defocusU and defocusV and copy the
# values from defocus
if (
"defocusU" not in df_particles.columns
and "defocus" in df_particles.columns
):
df_particles["defocusU"] = df_particles["defocus"]
if (
"defocusV" not in df_particles.columns
and "defocus" in df_particles.columns
):
df_particles["defocusV"] = df_particles["defocus"]

progressbar = tqdm(
total=len(df_particles),
desc="Writing starfiles",
Expand Down Expand Up @@ -463,8 +477,8 @@ def parse_df(self, df_particles):
image_name,
micrograph_filename,
str(self.optics_group),
"0", # CTF max resolution not used
"0", # CTF figure of merit not used
# "0", # CTF max resolution not used
# "1", # CTF figure of merit not used
str(row.get("defocusU", "0")),
str(row.get("defocusV", "0")),
"0", # defocus angle not used
Expand All @@ -476,11 +490,10 @@ def parse_df(self, df_particles):
str(np.rad2deg(row.get("euler_theta", "0"))),
"0", # origin x not used
"0", # origin y not used
"0", # norm correction not used
"0", # log likelihood contribution not used
"0", # max value prob distribution not used
"1", # nr of significant samples not used
"1", # random subset not used
# "0", # norm correction not used
# "0", # log likelihood contribution not used
# "0", # max value prob distribution not used
# "1", # nr of significant samples not used
]
)
progressbar.update(1)
Expand Down

0 comments on commit abfbcae

Please sign in to comment.