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

KeyError: 'badframes' #239

Closed
hummuscience opened this issue Sep 23, 2019 · 3 comments
Closed

KeyError: 'badframes' #239

hummuscience opened this issue Sep 23, 2019 · 3 comments

Comments

@hummuscience
Copy link

Updated everything to newest github version and getting the following error:

FOUND OPS IN /home/generalubuntu/mnt/Muad/ca-imaging/exp164-20190626/1drg-on/suite2p/plane0
** Found 10500 tifs - converting to binary **
800 frames of binary, time 90.87 sec.
1600 frames of binary, time 205.09 sec.
2400 frames of binary, time 316.45 sec.
3200 frames of binary, time 430.30 sec.
4000 frames of binary, time 543.19 sec.
4800 frames of binary, time 652.84 sec.
5600 frames of binary, time 763.69 sec.
6400 frames of binary, time 873.31 sec.
7200 frames of binary, time 979.14 sec.
8000 frames of binary, time 1089.90 sec.
8800 frames of binary, time 1197.45 sec.
9600 frames of binary, time 1304.87 sec.
10400 frames of binary, time 1412.46 sec.
time 1428.32 sec. Wrote tifs to binaries for 1 planes
SKIPPING REGISTRATION FOR ALL PLANES...
NOTE: binary file created, but registration not performed
>>>>>>>>>>>>>>>>>>>>> PLANE 0 <<<<<<<<<<<<<<<<<<<<<<

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-5-5e74ffea29ef> in <module>
     35 
     36     # run one experiment
---> 37     opsEnd=run_s2p.run_s2p(ops=ops,db=db)

~/Downloads/suite2p/suite2p/run_s2p.py in run_s2p(ops, db)
    242             if do_regmetrics and ops1[ipl]['nframes']>=1500:
    243                 t0=time.time()
--> 244                 ops1[ipl] = metrics.get_pc_metrics(ops1[ipl])
    245                 print('Registration metrics, %0.2f sec.'%(time.time()-t0))
    246                 np.save(os.path.join(ops1[ipl]['save_path'],'ops.npy'), ops1[ipl])

~/Downloads/suite2p/suite2p/register/metrics.py in get_pc_metrics(ops, use_red)
    154         mov  = sample_frames(ops, ix, ops['reg_file_chan2'])
    155     else:
--> 156         mov  = sample_frames(ops, ix, ops['reg_file'])
    157 
    158     pclow, pchigh, sv, v = pclowhigh(mov, nlowhigh, nPC)

~/Downloads/suite2p/suite2p/utils.py in sample_frames(ops, ix, reg_file, crop)
    150             frames x Ly x Lx
    151     """
--> 152     bad_frames = ops['badframes']
    153     ix = ix[bad_frames[ix]==0]
    154     Ly = ops['Ly']

KeyError: 'badframes'

Might be related to #181

@hummuscience
Copy link
Author

Resolved by deleting the already present suite2p folder and starting fresh.
It does seem to be connected with re-running the pipeline on already present data.

@ronan-dasilva
Copy link

The KeyError is happening because your last run of suite2p is skipping registration, likely because as you mentioned it found some pre-existing files. Do you know if your previous run was done until the end, or was it aborted before it could finish?

Essentially what happens is that if you abort the run before it can finish, suite2p never gets to the point of writing the entry ['badframes'] in the output ops file, so that when it tries to call this entry it creates an error.

However, if your previous trial was complete, then it means that your new run is overwriting the ops output file with one that lacks ['badframes'], which shouldn't be happening and should get fixed.

Let us know so we can try to fix this!

@carsen-stringer
Copy link
Member

thanks ronan for figuring that out, I've fixed it so that it's now backward-compatible hopefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants