Created
September 17, 2024 12:58
-
-
Save shahpnmlab/5589da84611c195642243ad2f9115445 to your computer and use it in GitHub Desktop.
starfile writing example
This file contains 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
import starfile | |
import pandas as pd | |
df_optics = pd.DataFrame({ | |
'rlnOpticsGroup': [1], | |
"rlnOpticsGroupName": ["OpticsGroup1"], | |
'rlnSphericalAberration': [2.7], | |
'rlnVoltage': [300], | |
'rlnImagePixelSize': [5], | |
'rlnImageDimensionality': [3] | |
}) | |
df_particles = pd.DataFrame({ | |
"rlnCoordinateX": [1, 32, 456, 456456], | |
"rlnCoordinateY": [1231231, 12312312, 12312312, 123213], | |
"rlnCoordinateZ": [1231231, 12312312, 12312312, 123213], | |
"rlnOpticsGroup": [1, 1, 1, 1] # Assuming all particles belong to the same optics group | |
}) | |
# Create a dictionary with both dataframes | |
star_data = { | |
'optics': df_optics, | |
'particles': df_particles | |
} | |
# Write the STAR file | |
starfile.write(star_data, "foo.star", overwrite=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment