Skip to content

Commit

Permalink
Create branch for execute in python >3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
josator2 committed Jun 7, 2023
1 parent 620af95 commit 2e7b807
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 126 deletions.
62 changes: 3 additions & 59 deletions xnat2mids/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,7 @@
This application allow the user to download one project on XNAT and
transform this project in MIDS format
There are 2 functions in this code:
download one project from xnat application:
arguments:
Prefix -w --web PAGE_WEB 1) The URL page where XNAT is.
Prefix -p --project [PROJECTS] 2) The project name to download
Prefix -i --input PATH 3) the directory where the files
will be downloaded
Prefix -u --user [USER] 4) The username to login in XNAT
If not write a username, It
loggin as guest.
Convert the xnat directories of the project in MIDS format:
arguments:
Prefix -i --input PATH 1) the directory where the files will
be downloaded
Prefix -o --output PATH 2) Directory where the MIDS model
is applied.
"""
###############################################################################
# Imports
Expand Down Expand Up @@ -93,49 +77,9 @@ def main():
This sorfware allows the user to Download one project into XNAT platform
and convert the XNAT images directory in MIDS directory.
The aplication execution needs Python --version >= 3.5.
there are 2 functions in this code:
Download temporary projects from xnat application:
arguments:
+ Prefix -w --web PAGE_WEB 1) The URL page where XNAT is.
+ Prefix -u --user [USER] 2) The username to login in XNAT
If not write a username, It logins
as guest.
+ Prefix -i --input INPUT 4) The directory where the
files will be downloaded.
+ Prefix -t --types [sdnbr] 5) Download types of MRI images
included in xnat
- d = dicom + dicom metadata in
folder NIFTI
- n = nifti or png if image is
one slide (2D) + roi
- b = BIDS (only in CENTRAL XNAT)
- r = Structural report
default = nr
The aplication execution needs Python --version >= 3.6.7
+ Prefix --overwrite 5) Overwrite download files
Convert the xnat directories of the project in MIDS format:
arguments:
+ Prefix -i --input INPUT 1) The directory where the files
will be downloaded.
+ Prefix -o --output OUTPUT 2) Directory where the MIDS model
is applied.
+ Prefix -bp --body-part 3) Specify which part of the body are
in the dataset(A clear dataset with
only one part are needed)
"""
"""
)
parser.add_argument('-w', '--web', type=str, default=None,
help='The URL page where XNAT is.')
Expand Down
6 changes: 3 additions & 3 deletions xnat2mids/mids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):

mids_session_path = mids_data_path.joinpath(subject_name, session_name)
xml_session_rois = list(sessions_xnat_path.rglob('*.xml'))
#print(f"1: {mids_session_path=}")
#print(f"1: {mids_session_path}")
tagger = Tagger()
tagger.load_table_protocol(
'./xnat2mids/protocols/protocol_RM_brain.tsv'
Expand Down Expand Up @@ -162,8 +162,8 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):
"
# print()
# print(modality, study_description, ProtocolName, image_type)
print(f"{study_description=}")
print(f"{Protocol_name=}")
print(f"{study_description}")
print(f"{Protocol_name}")
if modality == "MR":
# via BIDS protocols
#if study_description in LUMBAR_PROTOCOLS_ACEPTED:
Expand Down
4 changes: 2 additions & 2 deletions xnat2mids/procedures/light_procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def copy_sessions(self, subject_name):
df_aux.index = numpy.arange(1, len(df_aux) + 1)
print(len(df_aux))
activate_run = True if len(df_aux) > 1 else False
print(f"{activate_run=}")
print(f"{activate_run}")
for index, row in df_aux.iterrows():
activate_acq_partioned = True if len(row['run']) > 1 else False
for acq, file_ in enumerate(sorted(row['run'])):
Expand Down Expand Up @@ -64,7 +64,7 @@ def calculate_name(self, subject_name, key, num_run, num_part, activate_run, act
rec = f"{key_list[1] if key_list[1] else ''}"
chunk = f"{num_part if activate_acq_partioned else ''}"
run = f"{num_run if activate_run else ''}"
print(f"{run=}")
print(f"{run}")
# print(f"{key=}")
return "_".join([
part for part in [
Expand Down
4 changes: 2 additions & 2 deletions xnat2mids/procedures/magnetic_resonance_procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def control_sequences(
"" if body_part.lower() in body_part_bids else "mim-mr",
folder_BIDS
)
print(f'{folder_image_mids=}')
print(f'{folder_image_mids}')
folder_image_mids.mkdir(parents=True, exist_ok=True)


Expand Down Expand Up @@ -103,7 +103,7 @@ def calculate_name(self, subject_name, keys, num_run, num_part, activate_run, ac
print(num_part, activate_acq_partioned)
acq = f"{keys[1] if keys[1] else ''}"
chunk = f"{num_part if activate_acq_partioned else ''}"
print(f"{keys=}")
print(f"{keys}")
return "_".join([
part for part in [
subject_name,
Expand Down
8 changes: 4 additions & 4 deletions xnat2mids/protocols/scans_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def classification_by_min_max(self, dict_atrubutes):
image_type = dict_atrubutes["ImageType"]
#sequence_name = dict_atrubutes["SequenceName"]
#image_type = dict_atrubutes["ImageType"]
print(f"{scaning_sequence=:}")
print(f"{sequence_variant=:}")
print(f"{scan_options=:}")
print(f"{image_type=}")
print(f"{scaning_sequence}")
print(f"{sequence_variant}")
print(f"{scan_options}")
print(f"{image_type}")
#scaning_sequence = scaning_sequence if type(scaning_sequence) is str else "\\".join(scaning_sequence)

table_protocol_SS = self.table_protocols[[
Expand Down
71 changes: 15 additions & 56 deletions xnat2mids/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,62 +1,21 @@
absl-py==1.0.0
astunparse==1.6.3
async-timeout==4.0.2
beautifulsoup4==4.11.1
bs4==0.0.1
cachetools==5.1.0
certifi==2021.10.8
chardet==4.0.0
certifi==2021.5.30
charset-normalizer==2.0.12
Deprecated==1.2.13
flatbuffers==2.0
gast==0.5.3
google-auth==2.6.6
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.46.1
h5py==3.6.0
idna==3.3
imageio==2.19.1
keras==2.8.0
Keras-Preprocessing==1.1.2
libclang==14.0.1
lxml==4.8.0
Markdown==3.3.7
networkx==2.8
idna==3.4
importlib-resources==5.4.0
nibabel==3.2.2
npyscreen==4.10.5
numpy==1.22.3
oauthlib==3.2.0
opt-einsum==3.3.0
numpy==1.19.5
packaging==21.3
pandas==1.4.2
Pillow==9.1.0
progressbar2==4.0.0
protobuf==3.20.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pydicom==2.3.0
pyparsing==3.0.8
pandas==1.1.5
progressbar2==3.55.0
pydicom==2.3.1
pyparsing==3.0.9
python-dateutil==2.8.2
python-utils==3.1.0
pytz==2022.1
PyWavelets==1.3.0
redis==4.3.0
python-utils==3.5.2
pytz==2023.3
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.8
scikit-image==0.19.2
scipy==1.8.0
SimpleITK==2.1.1.2
six==1.16.0
soupsieve==2.3.2.post1
tensorboard==2.8.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.8.0
tensorflow-io-gcs-filesystem==0.25.0
termcolor==1.1.0
tf-estimator-nightly==2.8.0.dev2021122109
typing-extensions==4.2.0
urllib3==1.26.9
Werkzeug==2.1.2
wrapt==1.14.1
tqdm==4.64.1
typing_extensions==4.1.1
urllib3==1.26.16
zipp==3.6.0

0 comments on commit 2e7b807

Please sign in to comment.