@@ -44,20 +44,11 @@ def get_file_for_row_col(row, col):
4444 return all_files [index ] if index < len (all_files ) else None
4545
4646
47- def load_zarr_data (file_path ):
47+ def load_zarr_store (file_path ):
4848 zarr_store = zarr .open (file_path , mode = "r" )
4949 return zarr_store
5050
5151
52- def load_zarr_and_permute (file_path ):
53- zarr_store = zarr .open (file_path , mode = "r" )
54- # Input is in Z, T, C, Y, X order
55- # Want XYTCZ order
56- data = zarr_store [:]
57- data = np .transpose (data , (4 , 3 , 1 , 2 , 0 )) # Permute to XYTCZ
58- return zarr_store , data
59-
60-
6152def load_data_from_zarr_store (zarr_store ):
6253 # Input is in Z, T, C, Y, X order
6354 data = zarr_store [
@@ -76,31 +67,39 @@ def load_data_from_zarr_store(zarr_store):
7667 return data
7768
7869
79- zarr_store = load_zarr_data (all_files [0 ])
70+ zarr_store = load_zarr_store (all_files [0 ])
8071
8172# %% Inspect the data
8273shape = zarr_store .shape
8374# Input is in Z, T, C, Y, X order
8475# Want XYTCZ order
85- # single_file_shape = [shape[4], shape[3], shape[1], shape[2], shape[0]]
86- single_file_dims_shape = [shape [4 ], shape [3 ], shape [1 ]]
76+ single_file_xyz_shape = [shape [4 ], shape [3 ], shape [1 ]]
8777size_x = 1
8878size_y = 1
8979size_z = 1
80+ # Here, T and Z are kind of transferrable.
81+ # The reason is because the z dimension in neuroglancer is the time dimension
82+ # from the raw original data.
83+ # So both terms might be used to represent the same thing.
84+ # It's a bit unusual that t is being used as the z dimension,
85+ # but otherwise you can't do volume rendering in neuroglancer.
9086
9187num_channels = min (shape [2 ], NUM_CHANNELS ) # Limit to NUM_CHANNELS for memory usage
9288data_type = "uint16"
93- chunk_size = [64 , 64 , 32 ]
89+ chunk_size = [64 , 64 , 32 ] # chunk size in neuroglancer
90+ # The chunk size remains fixed across all mips, but at higher mips
91+ # the data will be downsampled, so the effective chunk size will be larger.
92+ # Because we use precomputed data format
93+ # Every chunk has to have all channels included
9494
9595volume_size = [
96- single_file_dims_shape [0 ] * NUM_ROWS ,
97- single_file_dims_shape [1 ] * NUM_COLS ,
98- single_file_dims_shape [2 ],
96+ single_file_xyz_shape [0 ] * NUM_ROWS ,
97+ single_file_xyz_shape [1 ] * NUM_COLS ,
98+ single_file_xyz_shape [2 ],
9999] # XYZ (T)
100100print ("Volume size:" , volume_size )
101101
102102# %% Setup the cloudvolume info
103- # TODO verify if non-axis aligned is ok or not
104103info = CloudVolume .create_new_info (
105104 num_channels = num_channels ,
106105 layer_type = "image" ,
@@ -149,7 +148,7 @@ def process(args):
149148 x_i , y_i , z_i = args
150149 file_to_load = get_file_for_row_col (x_i , y_i )
151150 print (f"Processing { file_to_load } at coordinates ({ x_i } , { y_i } , { z_i } )" )
152- loaded_zarr_store = load_zarr_data (file_to_load )
151+ loaded_zarr_store = load_zarr_store (file_to_load )
153152 start = [x_i * chunk_shape [0 ], y_i * chunk_shape [1 ], z_i * chunk_shape [2 ]]
154153 end = [
155154 min ((x_i + 1 ) * chunk_shape [0 ], shape [0 ]),
@@ -202,6 +201,13 @@ def process(args):
202201reversed_coords .reverse ()
203202
204203# %% Move the data across with multiple workers
204+ # TODO because we are using non-aligned writes, we can't use multiple workers
205+ # Or at least, we get a warning about it that I don't think we can ignore
206+ # if we want to use multiple workers, we'd need to fix this to have aligned writes
207+ # but that is trickier because we'd then need to load the data from multiple files
208+ # at the same time
209+ # Because one clean chunk in the data could be informed from multiple files
210+ # in the raw data
205211# max_workers = 8
206212
207213# with ProcessPoolExecutor(max_workers=max_workers) as executor:
0 commit comments