File size: 3,869 Bytes
27f8132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# recovar.data_io

Dataset loading, metadata extraction, and image access for cryo-EM and
cryo-ET data.

## Flow

```mermaid
flowchart TD
    A[CLI / pipeline args] --> B[halfsets.py<br/>split policy + halfset loading]
    A --> C[cryoem_dataset.py<br/>load_dataset(...)]
    C --> D[image_sources.py<br/>image source assembly]
    C --> E[metadata_readers.py<br/>STAR / CS metadata parsing]
    D --> F[image_backends.py<br/>file-backed SPA / cryo-ET loaders]
    F --> G[image_loader.py<br/>MRC / MRCS / HDF5 I/O]
    E --> H[image_metadata.py<br/>ImageMetadata]
    D --> I[_index_utils.py<br/>image/group remapping]
    B --> I
    D --> J[cryoem_dataset.py<br/>CryoEMDataset]
    H --> J
    I --> J
    B --> J
    J --> K[iter_batches(...)]
    K --> L[pipeline / compute_state / analyze]
```

```text
SPA / cryo-ET load path
  -> cryoem_dataset.load_dataset(...)
       -> image_sources.create_image_source(...)
            -> image_backends.py
            -> image_loader.py
       -> metadata_readers.auto_parse_poses / auto_parse_ctf
            -> image_metadata.ImageMetadata
       -> CryoEMDataset(...)

Halfset / subset path
  -> halfsets.get_split_indices / get_split_tilt_indices
  -> halfsets.load_halfset_dataset / load_halfset_dataset_from_args
  -> CryoEMDataset with halfset_indices

Downstream runtime path
  -> CryoEMDataset.iter_batches(...)
  -> explicit tuples:
     (images, rotation_matrices, translations, ctf_params, noise_variance, particle_indices, image_indices)

Cross-cutting indexing
  _index_utils.py
    - DatasetIndexLayout: local <-> original image/group ids
    - TiltSeriesOriginalIndexMap: particle <-> image ids in the original file
```

Keep these responsibilities separate:

- `image_sources.py` owns raw image access, lazy/eager loading, and subset views.
- `image_metadata.py` owns rotations, translations, and CTF rows.
- `cryoem_dataset.py` is the only high-level coordinator and batch iterator surface.
- `halfsets.py` owns split policy and halfset bookkeeping.
- `_index_utils.py` owns image/group/particle remapping logic.
- `image_backends.py` owns only the low-level stack and tilt-series loaders used underneath image sources.

Public surface used by the main runtime:

- `cryoem_dataset.load_dataset`
- `halfsets.load_halfset_dataset`
- `halfsets.load_halfset_dataset_from_args`
- `CryoEMDataset.iter_batches`
- `CryoEMDataset.subset`

## cryoem_dataset

Core dataset classes and loading functions.

::: recovar.data_io.cryoem_dataset
    options:
      members_order: source

## image_backends

Low-level Grain-backed image backends.

::: recovar.data_io.image_backends
    options:
      members_order: source

## image_sources

Raw image loading abstraction and subset/image-group remapping.

::: recovar.data_io.image_sources
    options:
      members_order: source

## image_metadata

Typed metadata container for poses and CTF rows.

::: recovar.data_io.image_metadata
    options:
      members_order: source

## halfsets

Halfset and split logic for SPA and cryo-ET.

::: recovar.data_io.halfsets
    options:
      members_order: source

## _index_utils

Canonical local/original image, group, and particle index mapping helpers.

::: recovar.data_io._index_utils
    options:
      members_order: source

## metadata_readers

Extract poses and CTF parameters from RELION `.star` and cryoSPARC `.cs` files.

::: recovar.data_io.metadata_readers
    options:
      members_order: source

## starfile

RELION `.star` file reading and writing.

::: recovar.data_io.starfile
    options:
      members_order: source

## load_utils

CTF and pose loading utilities (legacy pickle format).

::: recovar.data_io.load_utils
    options:
      members_order: source

## image_loader

Image loading from MRC/MRCS stacks and HDF5 files.

::: recovar.data_io.image_loader
    options:
      members_order: source