vodex.loaders module
This module contains classes to load and collect information from the imaging data.
The module contains the following classes:
-
TiffLoader
- A class to work with tiff image files. It is used to get the datatype of the images, get the number of frames in each tiff file and load frames from tiff files. You can create your own loaders to work with other file types. -
ImageLoader
- Chooses appropriate loader based on the type of the imaging files, collects information about the datatype, number of frames per file and loads data from files.
ImageLoader
Chooses appropriate loader based on the type of the imaging files, collects information about the datatype, number of frames per file and loads data from files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_example |
the path to a file example (one file from the whole dataaset). needed to get file type and initialise the corresponding data loader. |
required |
Attributes:
Name | Type | Description |
---|---|---|
loader_map |
Dict[str, type]
|
a dictionary that maps the file extensions to their loaders. |
supported_extension |
List[str]
|
list of all the supported file extensions. |
file_extension |
str
|
the file extension of the provided file example. |
loader |
Union[TiffFile]
|
a loader class initialised using the file example. |
Source code in src\vodex\loaders.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
get_frame_size(file_name)
Gets frame size ( height , width ) from an image files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
Union[str, Path]
|
the path to the file to get the size of the frame for. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
( height , width ) height and width of an individual frame in pixels. |
Source code in src\vodex\loaders.py
222 223 224 225 226 227 228 229 230 231 |
|
get_frames_in_file(file_name)
Calculates and returns the number of frames in a given file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
Union[str, Path]
|
the name of the file to get the number of frames for. |
required |
Returns:
Type | Description |
---|---|
int
|
the number of frames in the file. |
Source code in src\vodex\loaders.py
210 211 212 213 214 215 216 217 218 219 220 |
|
load_frames(frames, files, show_file_names=False, show_progress=True)
Loads specified frames from specified files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frames |
List[int]
|
list of frames IN FILES to load. |
required |
files |
Union[List[str], List[Path]]
|
a file for every frame |
required |
show_file_names |
bool
|
whether to print the names of the files from which the frames are loaded. Setting it to True will turn off show_progress. |
False
|
show_progress |
bool
|
whether to show the progress bar of how many frames have been loaded. Won't have effect of show_file_names is True. |
True
|
Returns:
Type | Description |
---|---|
np.ndarray
|
3D array of shape (n_frames, height, width) |
Source code in src\vodex\loaders.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
load_volumes(frame_in_file, files, volumes, show_file_names=False, show_progress=True)
Loads specified frames from specified files and shapes them into volumes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_in_file |
List[int]
|
list of frames IN FILES to load (relative to the beginning of the file from which you are loading). |
required |
files |
Union[List[str], List[Path]]
|
a file for every frame |
required |
volumes |
List[int]
|
a volume for every frame where that frame belongs |
required |
show_file_names |
bool
|
whether to print the names of the files from which the frames are loaded. Setting it to True will turn off show_progress. |
False
|
show_progress |
bool
|
whether to show the progress bar of how many frames have been loaded. Won't have effect of show_file_names is True. |
True
|
Returns:
Type | Description |
---|---|
np.ndarray
|
4D array of shape (number of volumes, zslices, height, width) |
Source code in src\vodex\loaders.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
TiffLoader
A class to work with tiff image files. It is used to get the datatype of the images, get the number of frames in each tiff file and load frames from tiff files. You can create your own loaders to work with other file types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_example |
Union[str, Path]
|
An example file file from the dataset to infer the frame size and data type. |
required |
Attributes:
Name | Type | Description |
---|---|---|
frame_size |
Tuple[int, int]
|
individual frame size (hight, width). |
data_type |
np.dtype
|
datatype. |
Source code in src\vodex\loaders.py
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 150 151 152 |
|
get_frame_dtype(file)
staticmethod
Gets the datatype of the frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
Union[str, Path]
|
the path to the file to get the datatype of the frame for. |
required |
Returns:
Type | Description |
---|---|
np.dtype
|
datatype of the frame. |
Source code in src\vodex\loaders.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
get_frame_size(file)
staticmethod
Gets frame size ( height , width ) from a tiff file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
Union[str, Path]
|
the path to the file to get the size of the frame for. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
( height , width ) height and width of an individual frame in pixels. |
Source code in src\vodex\loaders.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
get_frames_in_file(file)
staticmethod
Compute and return the number of frames in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
Union[str, Path]
|
the name of a file relative to data_dir to get the number of frames for. |
required |
Returns:
Type | Description |
---|---|
int
|
the number of frames in the file. |
Source code in src\vodex\loaders.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
load_frames(frames, files, show_file_names=False, show_progress=True)
Load frames from files and return as an array (frame, y, x).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frames |
List[int]
|
list of frames inside corresponding files to load |
required |
files |
Union[List[str], List[Path]]
|
list of files corresponding to each frame |
required |
show_file_names |
bool
|
whether to print the file from which the frames are loaded on the screen. |
False
|
show_progress |
bool
|
whether to show the progress bar of how many frames have been loaded. |
True
|
Returns:
Type | Description |
---|---|
np.ndarray
|
3D array of requested frames (frame, y, x) |
Source code in src\vodex\loaders.py
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 150 151 152 |
|