Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ WORKDIR $mc_path/multic/cli
RUN python -m slicer_cli_web.cli_list_entrypoint --list_cli
RUN python -m slicer_cli_web.cli_list_entrypoint MultiCompartmentSegment --help
RUN python -m slicer_cli_web.cli_list_entrypoint FeatureExtraction --help

RUN python -m slicer_cli_web.cli_list_entrypoint ReferenceFeatureExtraction --help

ENTRYPOINT ["/bin/bash", "docker-entrypoint.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import sys
from glob import glob
import girder_client
from ctk_cli import CLIArgumentParser

sys.path.append("..")
from segmentationschool.utils.json_to_xml import get_xml_path

NAMES = ['cortical_interstitium','medullary_interstitium','non_globally_sclerotic_glomeruli','globally_sclerotic_glomeruli','tubules','arteries/arterioles']


def main(args):

folder = args.base_dir
wsi = args.input_file
file_name = wsi.split('/')[-1]
base_dir_id = folder.split('/')[-2]
_ = os.system("printf '\nUsing data from girder_client Folder: {}\n'".format(folder))

gc = girder_client.GirderClient(apiUrl=args.girderApiUrl)
gc.setToken(args.girderToken)
# get files in folder
files = list(gc.listItem(base_dir_id))
# dict to link filename to gc id
item_dict = dict()
for file in files:
d = {file['name']:file['_id']}
item_dict.update(d)

file_id = item_dict[file_name]

cwd = os.getcwd()
print(cwd)
os.chdir(cwd)
tmp = folder
_ = os.system("printf '\n---\n\nFOUND: [{}]\n'".format(file_name))
# get annotation
annotations= gc.get('/annotation/item/{}'.format(file_id), parameters={'sort': 'updated'})
annotations.reverse()
annotations = list(annotations)

annotations_filtered = [annot for annot in annotations if annot['annotation']['name'].strip() in NAMES]
_ = os.system("printf '\tfound [{}] annotation layers...\n'".format(len(annotations_filtered)))
del annotations
# create root for xml file

xml_path = get_xml_path(annotations_filtered, NAMES, tmp, file_name)
_ = os.system("printf '\ndone retriving data...\n\n'")

cmd = "python3 ../segmentationschool/segmentation_school.py --option {} --base_dir {} --file {} --xml_path {} --platform {} --item_id {} --girderApiUrl {} --girderToken {}".format('get_features', args.base_dir, args.input_file, xml_path, 'DSA',file_id, args.girderApiUrl, args.girderToken)
print(cmd)
sys.stdout.flush()
os.system(cmd)

if __name__ == "__main__":
main(CLIArgumentParser().parse_args())
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<executable>
<category>HistomicsTK</category>
<title>Extract Extended Clinical Features</title>
<description>Extract reference features</description>
<version>0.1.0</version>
<documentation-url>https://github.com/SarderLab/Multi-Compartment-Segmentation</documentation-url>
<license>Apache 2.0</license>
<contributor>Sayat Mimar (UFL)</contributor>
<acknowledgements>This work is part of efforts in digital pathology by the Sarder Lab: UFL.</acknowledgements>
<parameters>
<label>IO</label>
<description>Input/output parameters</description>
<image>
<name>input_file</name>
<label>input_file</label>
<description>input file</description>
<channel>input</channel>
<index>0</index>
</image>
<directory>
<name>base_dir</name>
<label>Base Directory</label>
<description>Base Directory for the model</description>
<channel>input</channel>
<index>1</index>
</directory>
</parameters>
<parameters advanced="true">
<label>Girder API URL and Key</label>
<description>A Girder API URL and token for Girder client</description>
<string>
<name>girderApiUrl</name>
<longflag>api-url</longflag>
<label>Girder API URL</label>
<description>A Girder API URL (e.g., https://girder.example.com:443/api/v1)</description>
<default></default>
</string>
<string>
<name>girderToken</name>
<longflag>token</longflag>
<label>Girder API Token</label>
<description>A Girder token</description>
<default></default>
</string>
</parameters>
</executable>
3 changes: 3 additions & 0 deletions multic/cli/slicer_cli_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
},
"FeatureExtraction": {
"type" : "python"
},
"ReferenceFeatureExtraction": {
"type" : "python"
}
}
Loading