napari_ndev.helpers
#
Helper functions for file handling, image processing, and logging setup.
Functions:
-
get_directory_and_files : Get the directory and files in the specified directory.
– -
get_channel_names : Get the channel names from an AICSImage or BioImage object.
– -
get_squeezed_dim_order : Return a string containing the squeezed dimensions of the given AICSImage or BioImage object.
– -
create_id_string : Create an ID string for the given image.
– -
check_for_missing_files : Check if the given files are missing in the specified directories.
– -
setup_logger : Set up a logger with the specified log location.
–
check_for_missing_files
#
check_for_missing_files(files, *directories)
Check if the given files are missing in the specified directories.
Parameters:
-
files
(list of Path or list of str
) –List of files to check.
-
directories
(tuple of Path or str
, default:()
) –Tuple of directories to search for the files.
Returns:
-
list of tuple
–List of tuples containing the missing files and their corresponding directories.
Source code in src/napari_ndev/helpers.py
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 |
|
create_id_string
#
create_id_string(img, identifier)
Create an ID string for the given image.
Parameters:
-
img
(BioImage or AICSImage
) –The image object.
-
identifier
(str
) –The identifier string.
Returns:
-
str
–The ID string.
Examples:
>>> create_id_string(img, 'test')
'test__0__Scene:0'
Source code in src/napari_ndev/helpers.py
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 |
|
get_Image
#
get_Image(file)
Read the image file with BioImage or AICSImage.
Open the image file with BioImage, or if the file is not supported, open it with AICSImage.
Parameters:
Returns:
-
AICSImage or BioImage
–The image object.
Source code in src/napari_ndev/helpers.py
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 |
|
get_channel_names
#
get_channel_names(img)
Get the channel names from an AICSImage object.
If the image has a dimension order that includes "S" (it is RGB), return the default channel names ["red", "green", "blue"]. Otherwise, return the channel names from the image.
Parameters:
-
img
(AICSImage or BioImage
) –The AICSImage object.
Returns:
-
list of str
–The channel names.
Source code in src/napari_ndev/helpers.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
get_directory_and_files
#
get_directory_and_files(dir_path=None, pattern=None)
Get the directory and files in the specified directory.
Parameters:
-
dir_path
(str or Path or None
, default:None
) –The directory path.
-
pattern
(list of str or str or None
, default:None
) –The file pattern(s) to match. If a string is provided, it will be treated as a single pattern. If a list is provided, each element will be treated as a separate pattern. Defaults to ['tif', 'tiff', 'nd2', 'czi', 'lif', 'oib', 'png', 'jpg', 'jpeg', 'bmp', 'gif'].
Returns:
-
tuple of (Path, list of Path)
–A tuple containing the directory path and a list of file paths.
Source code in src/napari_ndev/helpers.py
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 |
|
get_squeezed_dim_order
#
get_squeezed_dim_order(img, skip_dims=None)
Return a string containing the squeezed dimensions of the given AICSImage object.
Parameters:
-
img
(AICSImage or BioImage
) –The AICSImage object.
-
skip_dims
(list of str or str or None
, default:None
) –Dimensions to skip. Defaults to ["C", "S"].
Returns:
-
str
–A string containing the squeezed dimensions.
Source code in src/napari_ndev/helpers.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
setup_logger
#
setup_logger(log_loc=Union[str, Path])
Set up a logger with the specified log location.
Parameters:
Returns:
-
logger
(Logger
) –The logger object.
-
handler
(FileHandler
) –The file handler object.
Source code in src/napari_ndev/helpers.py
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 |
|