|
21 | 21 | OUTPUT_PATH.mkdir(exist_ok=True, parents=True) |
22 | 22 | OVERWRITE = False |
23 | 23 | NUM_MIPS = 5 |
24 | | -MIP_CUTOFF = 3 # To save time you can start at the lowest resolution and work up |
25 | | -NUM_CHANNELS = 2 # For less memory usage (can't be 1 right now though) |
| 24 | +MIP_CUTOFF = 0 # To save time you can start at the lowest resolution and work up |
| 25 | +NUM_CHANNELS = 4 # For less memory usage (can't be 1 right now though) |
26 | 26 | NUM_ROWS = 3 |
27 | 27 | NUM_COLS = 6 |
28 | 28 | ALLOW_NON_ALIGNED_WRITE = True |
29 | 29 |
|
30 | 30 | # %% Load the data |
31 | 31 | OUTPUT_PATH.mkdir(exist_ok=True, parents=True) |
32 | | -# Need to figure out some sizes by checking the data |
| 32 | + |
| 33 | +# You don't need all files if you download them on demand |
| 34 | +# See get_file_for_row_col function |
33 | 35 | all_files = list(INPUTFOLDER.glob("**/*.zarr")) |
34 | 36 |
|
35 | 37 |
|
| 38 | +def get_file_for_row_col(row, col): |
| 39 | + """Get the file path for a specific row and column.""" |
| 40 | + if row < 0 or row >= NUM_ROWS or col < 0 or col >= NUM_COLS: |
| 41 | + raise ValueError("Row and column indices must be within the defined grid.") |
| 42 | + index = row * NUM_COLS + col |
| 43 | + # You could also download the file here and then delete it after use |
| 44 | + return all_files[index] if index < len(all_files) else None |
| 45 | + |
| 46 | + |
36 | 47 | def load_zarr_data(file_path): |
37 | 48 | zarr_store = zarr.open(file_path, mode="r") |
38 | 49 | return zarr_store |
@@ -136,10 +147,9 @@ def load_data_from_zarr_store(zarr_store): |
136 | 147 |
|
137 | 148 | def process(args): |
138 | 149 | x_i, y_i, z_i = args |
139 | | - flat_index = x_i * NUM_COLS + y_i |
140 | | - print(f"Processing chunk {flat_index} at coordinates ({x_i}, {y_i}, {z_i})") |
141 | | - # Load the data for this chunk |
142 | | - loaded_zarr_store = load_zarr_data(all_files[flat_index]) |
| 150 | + file_to_load = get_file_for_row_col(x_i, y_i) |
| 151 | + print(f"Processing {file_to_load} at coordinates ({x_i}, {y_i}, {z_i})") |
| 152 | + loaded_zarr_store = load_zarr_data(file_to_load) |
143 | 153 | start = [x_i * chunk_shape[0], y_i * chunk_shape[1], z_i * chunk_shape[2]] |
144 | 154 | end = [ |
145 | 155 | min((x_i + 1) * chunk_shape[0], shape[0]), |
|
0 commit comments