Skip to content
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

Feat(csparc2star): Add support for multi volume groups in CS v4.5+ #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions pyem/metadata/cryosparc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ def cryosparc_2_cs_model_parameters(cs, df=None, minphic=0):
if model[k] is not None:
name = u'alignments3D/' + k
df[model[k]] = pd.DataFrame(cs[name])
# CryoSPARC v4.5+
elif u'alignments3D_multi/class_posterior' in cs.dtype.names:
log.info("Assigning pose from most likely 3D classes using alignments3D_multi columns")
cls = np.argmax(cs['alignments3D_multi/class_posterior'], axis=1)
cls_prob = cs['alignments3D_multi/class_posterior'][range(cls.shape[0]), cls]
for k in model:
if model[k] is not None:
if k == u'split': # singleton column
df[model[k]] = pd.DataFrame(cs['alignments3D_multi/split'])
else:
df[model[k]] = pd.DataFrame(cs['alignments3D_multi/' + k][range(cls.shape[0]), cls, ...])

if minphic > 0:
df.drop(df.loc[cls_prob < minphic].index, inplace=True)
# CryoSPARC <= v4.4
elif len(phic_names) > 1:
log.info("Assigning pose from most likely 3D classes")
phic = np.array([cs[p] for p in phic_names if u'alignments2D' not in p])
Expand Down