Skip to content

Commit

Permalink
Update README and repare minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jomasator2 committed Jun 5, 2023
1 parent 8172d54 commit 620af95
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 79 deletions.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,38 @@ This sorfware allow the user to Download one project into XNAT platform (--versi
An example of execution is:

```sh
python3.5 main.py -w Project_id -i dirXNAT -o dirOutput
python3 -m xnat2mids -i DIR_TO_SAVE -w XNAT_WEB -u USER -b BODYPART -v
```

### Options

there are 2 funtions in this code:

Download one project from xnat aplicatión:

download one project from xnat aplicatión:
arguments:

arguments:
+ **-w (--web) XNAT_WEB** The ULR page where XNAT is.
+ **-i (--input) PATH** The directory where the the project will created.
+ **-u (--user) [USER]** The username to loggin in XNAT. If not write a username, It loggin as guest.
+ **-bp (--body-part) [BODY_PART]** Optional argument to clarify which part of the body are in the images. This argument is only used if the body part dicom tag is not found in the image.
+ **-v (--verbose)**

+ Prefix -w --web PAGE_WEB 1) The ULR page where XNAT is.
+ Prefix -p --project [PROJECTS] 2) The project name to download
+ Prefix -i --input PATH 3) the directfory where the files
will be downloaded
+ Prefix -u --user [USER] 4) The username to loggin in XNAT
If not write a username, It
loggin as guest.
If the xnat project is already downloaded. you can run the command by removing the -w and -u arguments.

Convert the xnat directories of the project in MIDS format:
arguments:
<a id='During Execution'></a>
## 4. During Execution
When we execute the programme, it will ask for the xnat user (if it was not set as an argument) and the password of our user.


Then The program will ask us which projects we want to pass to BIDS/MIDS. Just enter the numbers associated with the projects separated with space.

user: AAAAAAA
password:

1) p0012023 2) p0022021 3) p0022022 4) p0022023 5) p0032021
6) p0032023 7) p0042021 8) p0052021 9) p0052022 10) p0062021
Choose the project: 1 3 4

+ Prefix -i --input PATH 1) the directfory where the files will
be downloaded
+ Prefix -o --output PATH 2) Directory where the MIDS model
is applied.
<a id='future'></a>
## 4. Future Lines

Expand Down
12 changes: 8 additions & 4 deletions xnat2mids/mids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'ScanningSequence': '00180020',
'SequenceVariant': '00180021',
'ScanOptions': '00180022',
'ImageType': '00080008',
'AngioFlag': '00180025',
'MagneticFieldStrength': '00180087',
'RepetitionTime': '00180080',
Expand Down Expand Up @@ -95,7 +96,7 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):
procedure_class_light = LightProcedure()
for subject_xnat_path in tqdm(xnat_data_path.glob('*/')):
if "_S" not in subject_xnat_path.name:continue
num_sessions = len(list(subject_xnat_path.glob('*/')))
# num_sessions = len(list(subject_xnat_path.glob('*/')))
procedure_class_mr.reset_indexes()
procedure_class_light.reset_indexes()
for sessions_xnat_path in subject_xnat_path.glob('*/'):
Expand Down Expand Up @@ -135,7 +136,7 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):

print("---------", len(list(folder_conversion.iterdir())))
if len(list(folder_conversion.iterdir())) == 0: continue

#continue
dict_json = load_json(folder_conversion.joinpath(list(folder_conversion.glob("*.json"))[0]))


Expand All @@ -146,7 +147,10 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):
acquisition_date_time = dict_json.get("AcquisitionDateTime", "")
body_part = dict_json.get("BodyPartExamined", body_part)
acquisition_date_time_check = aquisition_date_pattern_comp.search(acquisition_date_time)
time_values = list(int (x) for x in acquisition_date_time_check.groups())
try:
time_values = list(int (x) for x in acquisition_date_time_check.groups())
except AttributeError as e:
continue
acquisition_date_time_correct = f"\
{time_values[0]:04d}-\
{time_values[1]:02d}-\
Expand All @@ -171,7 +175,7 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part):

protocol, acq, task, ce, rec, dir_, part, folder_BIDS = tagger.classification_by_min_max(json_adquisitions)
print(protocol, acq, task, ce, rec, dir_, part, folder_BIDS)
continue

procedure_class_mr.control_sequences(
folder_conversion, mids_session_path, session_name, protocol, acq, dir_, folder_BIDS, body_part
)
Expand Down
Loading

0 comments on commit 620af95

Please sign in to comment.