-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jermiah
committed
Nov 21, 2023
1 parent
201dda7
commit 4aac4e4
Showing
3 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,50 @@ | ||
from nbiatoolkit import NBIAClient | ||
import requests | ||
from pprint import pprint | ||
import multiprocessing as mp | ||
from tqdm import tqdm | ||
from tcia_utils import nbia | ||
import logging | ||
USERNAME = "sejinkim" | ||
PASSWORD = "q6mJyLD8cPeGTwg!" | ||
|
||
client = NBIAClient(log_level="DEBUG") | ||
# series = client.getSeries(Collection="4D-Lung") | ||
# pprint(series[0]) | ||
# print(type(series[0])) | ||
# print() | ||
|
||
# series0 = series[0]['SeriesInstanceUID'] | ||
series0 = '1.3.6.1.4.1.14519.5.2.1.6834.5010.189721824525842725510380467695' | ||
response = client.downloadSeries( | ||
SeriesInstanceUID = series0, | ||
downloadDir = "/home/bioinf/bhklab/jermiah/projects/NBIA-toolkit/resources") | ||
# pprint(response) | ||
|
||
client = NBIAClient(username=USERNAME, password=PASSWORD) | ||
series = client.getSeries(Collection="RADCURE") | ||
|
||
seriesList = [_["SeriesInstanceUID"] for _ in series] | ||
seriesList = seriesList[0:5] | ||
|
||
|
||
def download(series) -> bool: | ||
response = client.downloadSeries( | ||
SeriesInstanceUID = series, | ||
downloadDir = "/home/bioinf/bhklab/jermiah/projects/rawdata") | ||
return response | ||
|
||
if (True): | ||
# iterate through each series and download | ||
# print out the progressbar | ||
with mp.Pool(processes=30) as pool: | ||
for _ in tqdm(pool.imap_unordered(download, seriesList), total=len(seriesList)): | ||
pass | ||
else: | ||
_log = logging.getLogger(__name__) | ||
for handler in logging.root.handlers[:]: | ||
logging.root.removeHandler(handler) | ||
|
||
USERNAME = "sejinkim" | ||
PASSWORD = "q6mJyLD8cPeGTwg!" | ||
nbia.getToken(user=USERNAME, pw=PASSWORD) | ||
|
||
collection_name = "RADCURE" | ||
metadata = nbia.getSeries(collection = collection_name, format = "df", api_url = "restricted") | ||
|
||
nbia.downloadSeries(series_data = seriesList, path = "/home/bioinf/bhklab/jermiah/projects/rawdata", input_type = "list", api_url = "restricted") | ||
# with mp.Pool(processes=30) as pool: | ||
# for _ in tqdm(pool.imap_unordered(download, seriesList), total=len(seriesList)): | ||
# pass | ||
# python dicomsort.py -u /home/bioinf/bhklab/jermiah/projects/rawdata /home/bioinf/bhklab/jermiah/projects/NBIA-toolkit/resources/rawdata/%PatientID/%StudyDate-%StudyID-%StudyDescription-%StudyInstanceUID/%SeriesNumber-%SeriesDescription-%SeriesIntanceUID/%InstanceNumber-%SOPInstanceUID.dcm | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters