-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate_Downsampled_Mask_Dict.py
40 lines (29 loc) · 1.15 KB
/
Create_Downsampled_Mask_Dict.py
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
import os
import numpy as np
from skimage.transform import resize
def create_downsampled_mask_dict(base_directory):
print("Getting Downsampled Mask For Session; ", base_directory)
mask = np.load(os.path.join(base_directory, "Generous_Mask.npy"))
# Transform Mask
mask = resize(mask, (300, 304), preserve_range=True, order=0, anti_aliasing=True)
image_height = np.shape(mask)[0]
image_width = np.shape(mask)[1]
mask = np.where(mask > 0.1, 1, 0)
mask = mask.astype(int)
flat_mask = np.ndarray.flatten(mask)
indicies = np.argwhere(flat_mask)
indicies = np.ndarray.astype(indicies, int)
indicies = np.ndarray.flatten(indicies)
mask_dict = {
"indicies":indicies,
"image_height":image_height,
"image_width":image_width
}
np.save(os.path.join(base_directory, "Downsampled_mask_dict.npy"), mask_dict)
"""
base_directory = r"/media/matthew/External_Harddrive_2/Widefield_Data_New_Pipeline/Mutant_Data/NXAK16.1B"
session_list = os.listdir(base_directory)
for session in session_list:
session_directory = os.path.join(base_directory, session)
create_downsampled_mask_dict(session_directory)
"""