AssertionError during Homogenous Consensus Reconstruction
When trying to perform a homogeneous consensus reconstruction, i get an assertion error with this result: assert ctf_params.shape == (Nimg, 8)
I used this command: cryodrgn abinit_homo /home/earlab/Desktop/jdgf/krish/particles.128.mrcs --ctf /home/earlab/Desktop/jdgf/krish/ctf_particles.pkl -o /home/earlab/Desktop/jdgf/krish >> con_rec.log
I expected it to run for 30 epochs and refine the particles but was met with this error
How do I fix this? Is there a problem with my ctf parameters?
Yup seems like there's a problem with /home/earlab/Desktop/jdgf/krish/ctf_particles.pkl which either:
- does not have the same number of particle rows as
/home/earlab/Desktop/jdgf/krish/particles.128.mrcs(ctf_params.shape[0] != Nimg) - does not have the correct CTF format (number of field columns != 8)
Given where this error occurred, the former is far more likely, as upstream parsing of CTF parameters checks the latter condition before the code gets to this assert statement.
Can you take a look at this .ctf file (and the processes you used to make it) to see what might have gone wrong? E.g. the CTF array can be viewed in a Python session using:
import pickle
with open("ctf_particles.pkl", "rb") as f:
ctf_params = pickle.load(f)
Remember that the correct number of columns in a raw CTF is 9, not 8; as mentioned above, abinit_homo does some parsing of the CTF array before it gets to the assertion statement you are encountering. But as discussed above, it's likely the number of particles in the CTF that is the problem — did you use a filtering --ind set of indices at some point?
Hope this helps! -Mike
Hi Mike,
I implemented this code, however I'm unsure how to actually view the CTF array with this. Additionally, I printed ctf_params.shape[0], which returned a value of 176266. How can I check if this number matches the particle rows of our particles.128.mrcs file? In addition, how can I check the number of field columns?
In addition, we looked at the initial cryosparc file with:
import numpy as np
cs = np.load("/home/earlab/Desktop/jdgf/krish/exposures_ctf_estimated.cs")
print(cs.dtype.names)
This returned an array of 23 items, including ('uid', 'ctf/type', 'ctf/path', 'ctf/exp_group_id')...etc. Could these be the rows? If so, how can I check the columns instead?
Thanks! Anika
On Wed, Jul 17, 2024 at 2:21 PM Michal Grzadkowski @.***> wrote:
Yup seems like there's a problem with /home/earlab/Desktop/jdgf/krish/ctf_particles.pkl which either:
- does not have the same number of particle rows as /home/earlab/Desktop/jdgf/krish/particles.128.mrcs (ctf_params.shape[0] != Nimg)
- does not have the correct CTF format (number of field columns != 8)
Given where this error occurred, the former is far more likely, as upstream parsing of CTF parameters checks the latter condition before the code gets to this assert statement.
Can you take a look at this .ctf file (and the processes you used to make it) to see what might have gone wrong? E.g. the CTF array can be viewed in a Python session using:
import pickle with open("ctf_particles.pkl", "rb") as f: ctf_params = pickle.load(f)
Remember that the correct number of columns in a raw CTF is 9, not 8; as mentioned above, abinit_homo does some parsing of the CTF array before it gets to the assertion statement you are encountering. But as discussed above, it's likely the number of particles in the CTF that is the problem — did you use a filtering --ind set of indices at some point?
Hope this helps! -Mike
— Reply to this email directly, view it on GitHub https://github.com/ml-struct-bio/cryodrgn/issues/388#issuecomment-2233966113, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCWSXNJPWHENTBMNDKKQ4IDZM2Y3DAVCNFSM6AAAAABLBDXX36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZTHE3DMMJRGM . You are receiving this because you authored the thread.Message ID: @.***>
Hi --
Apologies for the double email! We figured out using ctf_params.shape[1] that we have 9 columns. Now I am just wondering how to check whether the number of particle rows matches in particles.128.mrcs and ctf_particles.pkl.
On Fri, Jul 19, 2024 at 1:23 PM Anika Madan @.***> wrote:
Hi Mike,
I implemented this code, however I'm unsure how to actually view the CTF array with this. Additionally, I printed ctf_params.shape[0], which returned a value of 176266. How can I check if this number matches the particle rows of our particles.128.mrcs file? In addition, how can I check the number of field columns?
In addition, we looked at the initial cryosparc file with:
import numpy as np
cs = np.load("/home/earlab/Desktop/jdgf/krish/exposures_ctf_estimated.cs")
print(cs.dtype.names)
This returned an array of 23 items, including ('uid', 'ctf/type', 'ctf/path', 'ctf/exp_group_id')...etc. Could these be the rows? If so, how can I check the columns instead?
Thanks! Anika
On Wed, Jul 17, 2024 at 2:21 PM Michal Grzadkowski < @.***> wrote:
Yup seems like there's a problem with /home/earlab/Desktop/jdgf/krish/ctf_particles.pkl which either:
- does not have the same number of particle rows as /home/earlab/Desktop/jdgf/krish/particles.128.mrcs (ctf_params.shape[0] != Nimg)
- does not have the correct CTF format (number of field columns != 8)
Given where this error occurred, the former is far more likely, as upstream parsing of CTF parameters checks the latter condition before the code gets to this assert statement.
Can you take a look at this .ctf file (and the processes you used to make it) to see what might have gone wrong? E.g. the CTF array can be viewed in a Python session using:
import pickle with open("ctf_particles.pkl", "rb") as f: ctf_params = pickle.load(f)
Remember that the correct number of columns in a raw CTF is 9, not 8; as mentioned above, abinit_homo does some parsing of the CTF array before it gets to the assertion statement you are encountering. But as discussed above, it's likely the number of particles in the CTF that is the problem — did you use a filtering --ind set of indices at some point?
Hope this helps! -Mike
— Reply to this email directly, view it on GitHub https://github.com/ml-struct-bio/cryodrgn/issues/388#issuecomment-2233966113, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCWSXNJPWHENTBMNDKKQ4IDZM2Y3DAVCNFSM6AAAAABLBDXX36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZTHE3DMMJRGM . You are receiving this because you authored the thread.Message ID: @.***>
No worries! To check the number of particle rows:
from cryodrgn.source import ImageSource
particles_fl = "/home/earlab/Desktop/jdgf/krish/particles.128.mrcs"
print(f"particles: {ImageSource.from_file(particles_fl).n}")