|
4 | 4 | import numpy as np |
5 | 5 |
|
6 | 6 | def setup_dataset(): |
7 | | - # Define the directories |
8 | | - base_dir = os.path.join(os.environ.get("BASE_DIR"),'dataset') |
| 7 | + # Define the base directory |
| 8 | + base_dir = os.path.join(os.environ.get("BASE_DIR"), 'dataset') |
9 | 9 |
|
| 10 | + # Define the code directories |
10 | 11 | dir_names = ["code0", "code1", "code2"] |
11 | 12 |
|
12 | 13 | # Create directories |
13 | 14 | for dir_name in dir_names: |
14 | 15 | os.makedirs(os.path.join(base_dir, dir_name), exist_ok=True) |
15 | 16 |
|
16 | | - |
17 | 17 | # Function to create the volume with a white center and optional shift |
18 | 18 | def create_volume(shift_x=0, shift_y=0, shift_z=0): |
19 | 19 | volume = np.zeros((10, 10, 10), dtype=np.uint16) |
20 | | - volume[4+shift_x:7+shift_x, 4+shift_y:7+shift_y, 4+shift_z:7+shift_z] = 65535 |
| 20 | + volume[4 + shift_x:7 + shift_x, 4 + shift_y:7 + shift_y, 4 + shift_z:7 + shift_z] = 65535 |
21 | 21 | return volume |
22 | 22 |
|
23 | 23 | # Create .h5 files with the modified properties |
24 | 24 | shifts = [(0, 0, 0), (1, 0, 0), (0, 1, 0)] # No shift, shift in x, shift in y |
25 | | - channels = ['640','594','561','488','405'] |
| 25 | + channels = ['640', '594', '561', '488', '405'] |
| 26 | + |
26 | 27 | for dir_index, dir_name in enumerate(dir_names): |
27 | | - for i,channel in zip(list(range(5)),channels): |
28 | | - file_path = os.path.join(base_dir, f"code{dir_index}/Channel{channel} SD_Seq000{i}.h5") |
29 | | - |
30 | | - # Create the volume with the appropriate shift |
31 | | - volume = create_volume(*shifts[dir_index]) |
32 | | - |
33 | | - # Save the volume in the .h5 file |
| 28 | + for fov_index in range(1): # Create 5 FOV files per code directory |
| 29 | + file_path = os.path.join(base_dir, f"{dir_name}/raw_fov{fov_index}.h5") |
| 30 | + |
| 31 | + # Create an empty volume and populate it with channels |
34 | 32 | with h5py.File(file_path, 'w') as f: |
35 | | - dataset_name = f"{channel}" |
36 | | - f.create_dataset(dataset_name, data=volume) |
| 33 | + for channel in channels: |
| 34 | + # Create the volume with the appropriate shift |
| 35 | + volume = create_volume(*shifts[dir_index]) |
| 36 | + dataset_name = f"{channel}" |
| 37 | + f.create_dataset(dataset_name, data=volume) |
37 | 38 |
|
38 | 39 | def cleanup_dataset(): |
39 | | - base_dir = os.path.join(os.environ.get("BASE_DIR"),'dataset') |
| 40 | + base_dir = os.path.join(os.environ.get("BASE_DIR"), 'dataset') |
40 | 41 | shutil.rmtree(base_dir, ignore_errors=True) |
41 | 42 |
|
42 | 43 | def pytest_sessionstart(session): |
|
0 commit comments