Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jomasator2 committed Aug 24, 2023
1 parent fdbaf7c commit 2239af8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
14 changes: 7 additions & 7 deletions xnat2mids/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ def main():
print(f"{xnat_data_path}")
print(f"{mids_data_path}")

# print("MIDS are generating...")
# create_directory_mids_v1(
# xnat_data_path,
# mids_data_path,
# body_part,
# debug_level
# )
print("MIDS are generating...")
create_directory_mids_v1(
xnat_data_path,
mids_data_path,
body_part,
debug_level
)

print("participats tsv are generating...")
create_tsvs(xnat_data_path, mids_data_path, body_part)
Expand Down
13 changes: 7 additions & 6 deletions xnat2mids/mids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from xnat2mids.conversion.dicom_converters import dicom2niix
from xnat2mids.conversion.dicom_converters import dicom2png
from tqdm import tqdm

from pandas.errors import EmptyDataError

adquisition_date_pattern = r"(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)T(?P<hour>\d+):(?P<minutes>\d+):(?P<seconds>\d+).(?P<ms>\d+)"
subses_pattern = r"[A-z]+(?P<prefix_sub>\d*)?(_S)(?P<suffix_sub>\d+)/[A-z]+\-?[A-z]*(?P<prefix_ses>\d*)?(_E)(?P<suffix_ses>\d+)"
prostate_pattern = r"(?:(?:(?:diff?|dwi)(?:\W|_)(?:.*)(?:b\d+))|dif 2000)|(?:adc|Apparent)|prop|blade|fse|tse"
prostate_pattern = r"(?:(?:(?:diff?|dwi)(?:\W|_)(?:.*)(?:b\d+))|dif 2000)|(?:adc|Apparent)|prop|blade|fse|tse|^ax T2$"

aquisition_date_pattern_comp = re.compile(adquisition_date_pattern)
prostate_pattern_comp = re.compile(prostate_pattern, re.I)
Expand Down Expand Up @@ -188,10 +188,11 @@ def create_directory_mids_v1(xnat_data_path, mids_data_path, body_part, debug_le
json_adquisitions = {
f'{k}': dict_json.get(k, -1) for k in dict_mr_keys.keys()
}

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)

try:
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)
except EmptyDataError as e:
continue
procedure_class_mr.control_sequences(
folder_conversion, mids_session_path, session_name, protocol, acq, dir_, folder_BIDS, body_part
)
Expand Down
2 changes: 1 addition & 1 deletion xnat2mids/protocols/protocol_RM_prostate.tsv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Protocol acq task rec ce dir part folder Manufacturer ManufacturersModelName ScanningSequence SequenceVariant ScanOptions SequenceName ImageType AngioFlag MagneticFieldStrength RepetitionTime InversionTime FlipAngle EchoTime NumberOfAverages RawImage DerivedVendorReportedEchoSpacing EffectiveEchoSpacing TotalReadoutTime
T2w propeller anat "[""GE""]" "[""SIGNA Architect"", ""Optima MR450w""]" "[""RM"", ""SE""]" "[""OSP"", ""SK""]" "[""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FSS_GEMS\\FILTERED_GEMS"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FSS_GEMS"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSI_GEMS"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSL_GEMS"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FSL_GEMS"", ""SAT_GEMS\\NPW\\NP\\EDR_GEMS\\TRF_GEMS\\ACC_GEMS\\SP\\FSL_GEMS\\FR_GEMS"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\SAT_GEMS\\FS\\TRF_GEMS\\FILTERED_GE"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSS_GEMS"", ""SAT_GEMS\\NPW\\NP\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_GEMS\\SP\\FSL_G"", ""FAST_GEMS\\PROP_GEMS\\NPW\\ACC_GEMS\\TRF_GEMS\\FILTERED_GEMS""]" [-1] "[[""DERIVED"", ""PRIMARY"", ""PROPELLER"", ""NONE""], [""ORIGINAL"", ""PRIMARY"", ""OTHER""], [""ORIGINAL"", ""PRIMARY"", ""PROPELLER"", ""NONE""]]" N [1.5, 3.0] [5.05891, 12.1146] [-1] [160.0, 160.0] [0.08688, 0.158752] [2.0, 3.0] [-1] [-1] [-1] [-1]
T2w blade anat "[""Siemens""]" "[""MAGNETOM Vida""]" "[""SE""]" "[""SP\\SK""]" "[""SP\\PER"", ""PER"", ""SP\\CG\\RG\\PER"", ""CG\\RG\\PER""]" "[""*tseB2d1_25"", ""*tseB2d1_40""]" "[[""ORIGINAL"", ""PRIMARY"", ""M"", ""NORM"", ""DIS2D"", ""MFSPLIT""]]" N [3.0, 3.0] [4.35, 12.75] [-1] [91.0, 160.0] [0.113, 0.167] [-1] [-1] [-1] [-1] [-1]
T2w fse anat "[""GE""]" "[""Signa HDxt"", ""SIGNA Architect"", ""Optima MR450w""]" "[""SE"", ""IR""]" "[""SK\\OSP"", ""SK""]" "[""FAST_GEMS\\SAT_GEMS\\MP_GEMS\\FILTERED_GEMS\\ACC_GEMS\\PFP\\FS"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\ACC_GEMS"", ""FAST_GEMS\\SAT_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_GEMS\\SP"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\FILTERE"",""FAST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ED_GEMS""]" [-1] "[[""ORIGINAL"", ""PRIMARY"", ""OTHER""]]" N [1.5, 3.0] [0.38, 8.98] [-1] [90.0, 180.0] [0.086108, 0.12624] [1.5, 2.0] [-1] [-1] [-1] [-1]
T2w fse anat "[""GE""]" "[""Signa HDxt"", ""SIGNA Architect"", ""Optima MR450w""]" "[""SE"", ""IR""]" "[""SK\\OSP"", ""SK""]" "[""FAST_GEMS\\FC_SLICE_AX_GEMS\\FC\\SAT_GEMS\\NPW\\EDR_GEMS\\TRF_GEMS\\FILT"", ""FAST_GEMS\\SAT_GEMS\\MP_GEMS\\FILTERED_GEMS\\ACC_GEMS\\PFP\\FS"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\ACC_GEMS"", ""FAST_GEMS\\SAT_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_GEMS\\SP"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\FILTERE"",""FAST_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_GEMS"", ""FAST_GEMS\\TRF_GEMS\\FILTERED_GEMS"", ""FAST_GEMS\\EDR_GEMS\\SS_GEMS\\FILTERED_GEMS\\ACC_GEMS\\PFP"", ""FAST_GEMS\\NPW\\NP\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_GEMS\\FSL_GEM"", ""FAST_GEMS\\VB_GEMS\\SS_GEMS\\PFP"", ""FAST_GEMS\\VB_GEMS\\SS_GEMS\\FILTERED_GEMS\\PFP"", ""FAST_GEMS\\SAT_GEMS\\NPW\\NP\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\SP\\FS"", ""FAST_GEMS\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSA_GEMS"", ""FAST_GEMS\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSI_GEMS"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS"", ""FAST_GEMS\\SAT_GEMS\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\SP\\FSP_GEM"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\NPW\\EDR_GEMS\\TRF_GEMS"", ""FAST_GEMS\\FC_SLICE_AX_GEMS\\FC\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS"", ""FAST_GEMS\\SS_GEMS\\FILTERED_GEMS\\ACC_GEMS\\PFP"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\SAT_GEMS\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTE"", ""FAST_GEMS\\NPW\\NP\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS\\FSI_GEMS"", ""FAST_GEMS\\SS_GEMS\\FILTERED_GEMS\\PFP"", ""FAST_GEMS\\FC_FREQ_AX_GEMS\\FC\\NPW\\EDR_GEMS\\TRF_GEMS\\FILTERED_GEMS""]" [-1] "[[""ORIGINAL"", ""PRIMARY"", ""OTHER""]]" N [1.5, 3.0] [0.38, 8.98] [-1] [90.0, 180.0] [0.086108, 0.12624] [1.5, 2.0] [-1] [-1] [-1] [-1]
T2w fse anat "[""Siemens""]" "[""MAGNETOM Vida""]" "[""SE""]" "[""SP\\SK""]" "[""PER"", ""PFP\\CG\\RG\\PER"", ""SP\\CG\\RG\\PER"", ""CG\\RG\\PER""]" "[""*tse2d1_25"", ""*tseB2d1_25"", ""*tir2d1_7""]" "[[""ORIGINAL"", ""PRIMARY"", ""M"", ""NORM"", ""DIS2D"", ""MFSPLIT""], [""ORIGINAL"", ""PRIMARY"", ""M"", ""DIS2D"", ""NORM"", ""MFSPLIT""]]" N [3.0, 3.0] [4.16, 11.19] [-1] [117.0, 160.0] [0.038, 0.129] [2.0, 4.0] [-1] [-1] [-1] [-1]
T2w fse anat "[""Philips""]" "[""Ingenia CX"", ""MR 5300""]" "[""SE""]" "[""SK""]" "[""SP"", ""OTHER""]" [-1] "[[""ORIGINAL"", ""PRIMARY"", ""M"", ""SE"", ""M"", ""SE""]]" N [1.5, 1.5] [6.0, 9.14193] [-1] [90.0, 90.0] [0.12, 0.12] [2.0, 2.0] [-1] [-1] [-1] [-1]
stir fse anat "[""GE""]" "[""Signa Hdxt""]" "[""RM""]" "[""OSP"", ""NONE""]" "[""FC_FREQ_AX_GEMS\\FC\\SAT_GEMS\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\FILTERED_G"", ""FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\FILTERED_GEMS\\ACC_G"", ""FC_FREQ_AX_GEMS\\FC\\NPW\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS"", ""FC_SLICE_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\ACC_GEMS"", ""FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS"", ""FC_FREQ_AX_GEMS\\FC\\EDR_GEMS\\SEQ_GEMS\\TRF_GEMS\\ACC_GEMS""]" [-1] "[[""ORIGINAL"", ""PRIMARY"", ""OTHER""]]" N [3.0, 3.0] [3.32, 6.24] [0.18, 0.18] [90.0, 90.0] [0.0328, 0.054288] [2.0, 2.0] [-1] [-1] [-1] [-1]
Expand Down
3 changes: 2 additions & 1 deletion xnat2mids/protocols/scans_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import json
pd.set_option('display.max_columns', None)

from pandas.errors import EmptyDataError
class Tagger:
# scan group
# SE = Spin Echo =====>>>> 'SE'
Expand Down Expand Up @@ -45,6 +45,7 @@ def classification_by_min_max(self, dict_atrubutes):
print("#" * 40, "table_protocol_M", "#" * 40)
print(table_protocol_M[["Protocol", "acq"]])

if table_protocol_M.empty: raise EmptyDataError

table_protocol_M_SS = table_protocol_M[[
any([True for s in json.loads(l) if s == scaning_sequence])
Expand Down

0 comments on commit 2239af8

Please sign in to comment.