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 BioImage object.
– -
get_squeezed_dim_order : Return a string containing the squeezed dimensions of the given 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
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 |
|
create_id_string
#
create_id_string(img, identifier)
Create an ID string for the given image.
Parameters:
Returns:
-
str
–The ID string.
Examples:
>>> create_id_string(img, 'test')
'test__0__Scene:0'
Source code in src/napari_ndev/helpers.py
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 |
|
get_Image
#
get_Image(file)
Read the image file with BioImage.
Open the image file with BioImage.
Parameters:
Returns:
-
BioImage
–The image object.
Source code in src/napari_ndev/helpers.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
get_channel_names
#
get_channel_names(img)
Get the channel names from a BioImage 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
#BioImage
) –The BioImage object.
Returns:
-
list of str
–The channel names.
Source code in src/napari_ndev/helpers.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
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
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 |
|
get_squeezed_dim_order
#
get_squeezed_dim_order(img, skip_dims=None)
Return a string containing the squeezed dimensions of the given BioImage.
Parameters:
-
img
#BioImage
) –The BioImage 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
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
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
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 |
|