-
Notifications
You must be signed in to change notification settings - Fork 102
Feature slide info #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
0ab3a0f
3a24650
3477f52
6921300
c67d8b0
6a6845e
f7b0c0c
7381339
eb4a990
f06b659
1ba8c42
02747bb
5f63b4a
34b9bd6
6f3ffaa
68d2177
6811a98
ab43935
045ef83
a24e4a5
e837fb7
1285e6b
abfa632
eabf091
ee19869
5b1c768
3b78fc1
a70831d
82cf63c
60e7d69
08ab342
573fa08
f547d2d
b0ff26e
3d9f6e4
2ed615e
2661de6
e180dd6
0847184
a2e2a81
66dac0f
b49ec89
e80e860
b9b6dd5
ff3073b
ad355c4
d7ea162
dc5d144
d3af79a
322286c
8849f62
3970513
8b11fc8
9cbb54b
3fbd942
90b7140
84187a8
00b0c28
8a459f0
5dfa112
bd45034
bc81b2b
72f2b5d
2726d98
7e8dcf4
4614f7f
eff04cf
8fc06d6
8398bb4
8af253a
1d99de1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,6 @@ | |
| __author__ = """TIA Lab""" | ||
| __email__ = "[email protected]" | ||
| __version__ = "0.1.1" | ||
|
|
||
| if __name__ == "__main__": | ||
| pass | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| from tiatoolbox.dataloader import slide_info | ||
| from tiatoolbox.dataloader import wsireader | ||
| """ | ||
| Package to read whole slide images | ||
| """ | ||
|
|
||
| from tiatoolbox.dataloader import slide_info, wsireader |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| """ | ||
| This file contains code to output or save slide information using python multiprocessing | ||
| Get Slide Meta Data information | ||
| """ | ||
| from tiatoolbox.dataloader import wsireader | ||
| from tiatoolbox.decorators.multiproc import TIAMultiProcess | ||
|
|
@@ -8,43 +8,39 @@ | |
|
|
||
|
|
||
| @TIAMultiProcess(iter_on="input_path") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a style preference here. Having a capitalised decorator like this just looks wrong. They are usually defined in a from numba import jit
@jit(nopython=True)
def do_something_useful():
passor a function of a class e.g. in flask apps: from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class name shouldn't it be PascalCase? |
||
| def slide_info(input_path, output_dir=None, mode="show"): | ||
| def slide_info(input_path, output_dir=None): | ||
| """ | ||
| slide_info() | ||
| Single file run to output or save WSI meta data. Multiprocessing uses this function to run slide_info in parallel | ||
| Args: | ||
| input_path: Path to whole slide image | ||
| output_dir: Path to output directory to save the output | ||
| mode: "show" to display meta information only or "save" to save the meta information | ||
|
|
||
| Returns: | ||
| displays or saves WSI meta information | ||
|
|
||
shaneahmed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Examples: | ||
| >>> from tiatoolbox.dataloader.slide_info import slide_info | ||
| >>> from tiatoolbox import utils | ||
| >>> file_types = ("*.ndpi", "*.svs", "*.mrxs") | ||
| >>> files_all = utils.misc.grab_files_from_dir(input_path, file_types=file_types) | ||
| >>> slide_params = slide_info(input_path=files_all, workers=2) | ||
| >>> for slide_param in slide_params: | ||
| >>> utils.misc.save_yaml(slide_param, slide_param["file_name"] + ".yaml") | ||
| >>> print(type(slide_param)) | ||
|
|
||
| """ | ||
|
|
||
| input_dir, file_name = os.path.split(input_path) | ||
|
|
||
| if output_dir is None: | ||
| output_dir = os.path.join(input_dir, "..", "meta") | ||
|
|
||
| if mode is None: | ||
| mode = "show" | ||
|
|
||
| if not os.path.isdir(output_dir) and mode == "save": | ||
| os.makedirs(output_dir, exist_ok=True) | ||
|
|
||
| print(file_name, flush=True) | ||
| _, file_type = os.path.splitext(file_name) | ||
|
|
||
| if file_type == ".svs" or file_type == ".ndpi" or file_type == ".mrxs": | ||
| wsi_reader = wsireader.WSIReader( | ||
| input_dir=input_dir, file_name=file_name, output_dir=output_dir | ||
| ) | ||
| if mode == "show": | ||
| info = wsi_reader.slide_info(save_mode=False) | ||
| print(info) | ||
| return info | ||
| else: | ||
| wsi_reader.slide_info( | ||
| output_dir=output_dir, output_name=file_name + ".yaml" | ||
| ) | ||
| return os.path.join(output_dir, file_name + ".yaml") | ||
| info = wsi_reader.slide_info() | ||
| return info | ||
| else: | ||
| print("File type not supported") | ||
| return None | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ | ||
| Decorators init file | ||
| Package defines decorators for the toolbox | ||
shaneahmed marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| from tiatoolbox.decorators import multiproc | ||
Uh oh!
There was an error while loading. Please reload this page.