Skip to content

Commit

Permalink
Merge pull request #272 from zhonge/preprocess_ind
Browse files Browse the repository at this point in the history
Filter preprocessed dataset before loading
  • Loading branch information
zhonge authored May 1, 2023
2 parents 304abea + 26951b4 commit 13d43b8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cryodrgn/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,17 @@ class PreprocessedMRCData(data.Dataset):

def __init__(self, mrcfile, norm=None, ind=None, lazy=False, use_cupy=False):
self.use_cupy = use_cupy
particles = load_particles(mrcfile, lazy=lazy)
self.lazy = lazy
if ind is not None:
particles = particles[ind]

# First lazy load to avoid loading the whole dataset
particles = load_particles(mrcfile, True)
if not lazy:
# Then, load the desired particles specified by ind
particles = np.array([particles[i].get() for i in ind])
else:
particles = particles[ind]
else:
particles = load_particles(mrcfile, lazy=lazy)
self.lazy = lazy
self.particles = particles
self.N = len(particles)
if self.lazy:
Expand Down

0 comments on commit 13d43b8

Please sign in to comment.