GCTF from particles.star from Relion - keep getting particles_dset reference UnboundLocalError

Hello everyone,
I am trying to do local CTF estimation on my particles, as I collected tilt data and want to be more accurate. I had issues generating particle.star files from .cs files and importing them to use (they kept failing GCTF due to lacking rlnMicrograph, or the issue I will talk about), so I did processing in relion 4.0, and couldn’t do GCTF CTF estimation on that due to lacking CUDA 8.0 on that server. So I brought over the particles.star file.

I had to Ignore raw and pose data or it complained about not having certain inputs (due to looking for files in /Extract from Relion 4). I used the CTF estimation job from Cryosparc to get the micrograph information as input.

The error I keep getting is this:

Why do I keep getting this, and how do I get around it?
I also noticed that I can’t do local estimation without refining input CTF information - do I need to add this? Where do I get it from?

Thanks for the help.

Hi @Matthew_J_Jackman, the GCTF wrapper requires the blob and location inputs in the Particle stacks input group to be connected in order to perform local CTF estimation. Can you check that this is the case?

@kwang Hmm, I don’t think they were, so that’s probably what the issue was.
I realised that I needed to have the files on the same workstation, so I moved my project to the same workstation, and imported the micrographs from my motioncorr job so I could use it to import the particle.star information using the import particle stacks job.
However, now I am running into a new issue, which is that I get this error:

I suspect this is because it wants CTF information from my micrographs (but they are only after Motion correction). I can’t seem to import the micrographs from CTF estimation (they have some sort of link to the motioncorr micrographs and CryoSPARC doesn’t like it), and I noticed that whenever I want to run local refine, it automatically turns on “do CTF refine”, which I don’t want. Is there any way to only do local refine without the CTF refine, or is that always done as well? Otherwise, I can’t think of a way around this. It does say to include an input micrograph_ctf.star file when doing multiple micrographs (under Gctf I/o options), which I imagine is to link the CTF estimation information from the CtfFind job in Relion, but I am not sure how to actually make it find/read that star file. Does it need to be in a specific location? I’m not sure what to do.

Well, I tried to do GCtf with a single micrograph (ran GCTF without local refine to only have a single micrograph due to it being the only one to contain particles) and then ran it on GCtf again with local refine… now I get the lrnMicrograph error. I would think there shouldn’t be an issue with the Micrograph name given it was imported fine, but apparently that didn’t work.

Getting local refine to work on GCtf seems to be extremely finniky. If anyone has a general walkthrough of what they did to get it to work for them (either from Relion or doing csparc2star from CryoSPARC inputs), I would be very grateful. There’s little to no documentation on doing local refine for GCtf, so I am very much in the dark here.

Hi @Matthew_J_Jackman,

Local CTF refinement is a sub-option of CTF refinement, so you do need to provide input CTFs for a local CTF refinement GCTF job. The workflow should be to run GCTF once to get the global CTF parameters (you can disconnect the particles input to process all the micrographs), and then pass the output into another GCTF job, this time with the particles input connected and local refinement turned on.

About micrograph_ctf.star, the CryoSPARC wrapper should automatically generate the file from the input CTF data, so you don’t need to worry about providing it.

The lrnMicrograph error is caused by bugs in the wrapper code. Deleting these lines in cryosparc_worker/cryosparc_compute/jobs/ctf/run.py should allow the job to run:

line 705: star_df = star_df.drop(ctf_fields,axis=1)
line 873: particles_dset.data['ctf/fig_of_merit_gctf'][idx] = d['rlnCtfFigureOfMerit']

These changes should also be in an upcoming patch to CryoSPARC v4. Thanks for reporting!

1 Like