fedorov
(Andrey Fedorov)
June 1, 2023, 5:53pm
1
I have a python package declared within the extension, and I can import it directly when accessing from the extension code. How can I import that extension in the Slicer python console?
I’ve done this before, I know it is possible, but I cannot find it in the hierarchies of slicer.modules.*
etc.
rbumm
(Rudolf Bumm)
June 1, 2023, 7:25pm
2
Do you mean something like this?
self.showStatusMessage(' Importing lungmask AI ...')
try:
import lungmask
except ModuleNotFoundError:
self.showStatusMessage(' Installing lungmask AI ...')
lungmaskPackage = "https://github.com/JoHof/lungmask/archive/master.zip"
slicer.util.pip_install(lungmaskPackage)
import lungmask
1 Like
fedorov
(Andrey Fedorov)
June 1, 2023, 8:05pm
3
With the help of @DeepaKrishnaswamy I figured this out.
To be more specific, I wanted to import this package:
import json, string
import urllib.request, urllib.parse, urllib.error
import urllib.parse
#import TCIABrowserLib
#
# Refer https://wiki.cancerimagingarchive.net/display/Public/REST+API+Usage+Guide for complete list of API
#
class TCIAClient:
GET_IMAGE = "getImage"
GET_MANUFACTURER_VALUES = "getManufacturerValues"
GET_MODALITY_VALUES = "getModalityValues"
GET_COLLECTION_VALUES = "getCollectionValues"
GET_BODY_PART_VALUES = "getBodyPartValues"
GET_PATIENT_STUDY = "getPatientStudy"
GET_SERIES = "getSeries"
GET_SERIES_SIZE = "getSeriesSize"
GET_PATIENT = "getPatient"
# use Slicer API key by default
This file has been truncated. show original
Which is part of this extension:
Which is very simple once you know how to do it. I hope I will remember it for the next time!
from TCIABrowser import TCIAClient
2 Likes