From 0673182e61cd9e6b94d162aa01960bd16d2dea83 Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Tue, 19 Oct 2021 03:36:32 -0400 Subject: [PATCH] Bugfixes --- imaging_install.sh | 11 +++++++---- imaging_install_MacOSX.sh | 11 +++++++---- python/bids_import.py | 2 +- python/lib/api.py | 4 +++- python/lib/bidsreader.py | 27 ++++++++++++++++++--------- python/lib/database.py | 4 ++-- python/lib/session.py | 4 ++++ 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/imaging_install.sh b/imaging_install.sh index 21f859608..eb2096c9d 100755 --- a/imaging_install.sh +++ b/imaging_install.sh @@ -40,7 +40,8 @@ if [ ! -f "$MAKECHECK" ]; then exit fi -echo "-- LORIS DB Configuration --\n" +echo "" +echo "-- LORIS DB Configuration --" read -p "What is the database name? " mysqldb read -p "What is the database host? " mysqlhost read -p "What is the MySQL user? " mysqluser @@ -48,15 +49,17 @@ stty -echo read -p "What is the MySQL password? " mysqlpass; echo stty echo -echo "-- LORIS API Configuration --\n" +echo "" +echo "-- LORIS API Configuration --" read -p "What is the LORIS url (including http(s))? " lorishost read -p "What is the API version (min v0.0.4-dev recommended)? " apiversion read -p "What is the LORIS admin user? " lorisuser stty -echo -read -p "What is the LORIS user admin password? " lorispass; echo +read -p "What is the LORIS user admin password? " lorispwd; echo stty echo -echo "-- LORIS MRI Configuration --\n" +echo "" +echo "-- LORIS MRI Configuration --" read -p "What is the Linux user which the installation will be based on? " USER read -p "What is the project name? " PROJ ##this will be used to create all the corresponding directories...i.e /data/gusto/bin..... read -p "What is your email address? " email diff --git a/imaging_install_MacOSX.sh b/imaging_install_MacOSX.sh index a3188c4a0..42f642cb8 100755 --- a/imaging_install_MacOSX.sh +++ b/imaging_install_MacOSX.sh @@ -22,7 +22,8 @@ LOGFILE="/tmp/$(basename $0).$$.tmp" touch $LOGFILE trap "rm $LOGFILE" EXIT -echo "-- LORIS DB Configuration --\n" +echo "" +echo "-- LORIS DB Configuration --" read -p "What is the database name? " mysqldb read -p "What is the database host? " mysqlhost read -p "What is the MySQL user? " mysqluser @@ -30,15 +31,17 @@ stty -echo read -p "What is the MySQL password? " mysqlpass; echo stty echo -echo "-- LORIS API Configuration --\n" +echo "" +echo "-- LORIS API Configuration --" read -p "What is the LORIS url (including http(s))? " lorishost read -p "What is the API version (min v0.0.4-dev recommended)? " apiversion read -p "What is the LORIS admin user? " lorisuser stty -echo -read -p "What is the LORIS user admin password? " lorispass; echo +read -p "What is the LORIS user admin password? " lorispwd; echo stty echo -echo "-- LORIS MRI Configuration --\n" +echo "" +echo "-- LORIS MRI Configuration --" read -p "What is the Linux user which the installation will be based on? " USER read -p "What is the project name? " PROJ ##this will be used to create all the corresponding directories...i.e /data/gusto/bin..... read -p "What prod file name would you like to use? default: prod " prodfilename diff --git a/python/bids_import.py b/python/bids_import.py index 078147a99..21e228886 100755 --- a/python/bids_import.py +++ b/python/bids_import.py @@ -214,7 +214,7 @@ def read_and_insert_bids(bids_dir, config_file, verbose, createcand, createvisit for scan_data in bids_reader.bids_layout.get_collections('session', 'scans') ]) - if len(scans_data.get('acq_time')) == 0: + if 'acq_time' not in scans_data.columns: message = '\n\tERROR: Can\'t find scans acquisition time data' print(message) sys.exit(lib.exitcode.BIDS_SCANS_ACQ_TIME_MISSING) diff --git a/python/lib/api.py b/python/lib/api.py index e7e2769d8..fe502daf3 100644 --- a/python/lib/api.py +++ b/python/lib/api.py @@ -13,6 +13,8 @@ class Api: the LORIS-MRI python code base and the LORIS backend. """ + token = None + def __init__(self, config, verbose): """ Constructor method for the Api class. @@ -69,7 +71,7 @@ def start_next_stage(self, candid, visit, site, subproject, project, date): verify=False ) - if (resp.status and resp.status.code and resp.status.code == 200): + if (resp.status_code and resp.status_code == 200): print("Next stage successfully started.") else: print("An error occured. Can't start next stage.") diff --git a/python/lib/bidsreader.py b/python/lib/bidsreader.py index 1442d871a..ed408da87 100644 --- a/python/lib/bidsreader.py +++ b/python/lib/bidsreader.py @@ -96,15 +96,24 @@ def load_bids_data(self): bids_pack_version = list(map(int, bids.__version__.split('.'))) # disabled until is a workaround for https://github.com/bids-standard/pybids/issues/760 is found # [file] bids_import.py [function] read_and_insert_bids [line] for modality in row['modalities']: (row['modalities'] is empty) - #if (bids_pack_version[0] > 0 - # or bids_pack_version[1] > 12 - # or (bids_pack_version[1] == 12 and bids_pack_version[2] > 0)): - # bids_layout = BIDSLayout( - # root=self.bids_dir, - # indexer=BIDSLayoutIndexer(config_filename=bids_config, ignore=exclude_arr, force_index=force_arr) - # ) - #else: - bids_layout = BIDSLayout(root=self.bids_dir, config=bids_config, ignore=exclude_arr, force_index=force_arr, derivatives=True) + ''' + if (bids_pack_version[0] > 0 + or bids_pack_version[1] > 12 + or (bids_pack_version[1] == 12 and bids_pack_version[2] > 0)): + bids_layout = BIDSLayout( + root=self.bids_dir, + indexer=BIDSLayoutIndexer(config_filename=bids_config, ignore=exclude_arr, force_index=force_arr), + derivatives=True + ) + else: + ''' + bids_layout = BIDSLayout( + root=self.bids_dir, + config=bids_config, + ignore=exclude_arr, + force_index=force_arr, + derivatives=True + ) if self.verbose: print('\t=> BIDS dataset loaded with BIDS layout\n') diff --git a/python/lib/database.py b/python/lib/database.py index 88743c2ba..0c6adcec5 100644 --- a/python/lib/database.py +++ b/python/lib/database.py @@ -253,8 +253,8 @@ def grep_id_from_lookup_table(self, id_field_name, table_name, where_field_name, ) if not id: - message = "\nERROR: " + where_value + " " + where_field_name + \ - " does not exist in " + table_name + " database table\n" + message = "\nERROR: " + str(where_value) + " " + str(where_field_name) + \ + " does not exist in " + str(table_name) + " database table\n" print(message) sys.exit(lib.exitcode.SELECT_FAILURE) diff --git a/python/lib/session.py b/python/lib/session.py index d89758adc..fa433b83c 100644 --- a/python/lib/session.py +++ b/python/lib/session.py @@ -128,6 +128,10 @@ def start_visit_stage(self, db, api, visit_date): if self.verbose: print("Starting visit stage for " + self.visit_label + " and CandID " + self.cand_id) + if not self.subproject_id or not self.project_id: + print("Can't start the visit stage - No subproject and project associated with the participant data.") + return + site = db.grep_id_from_lookup_table('Name', 'psc', 'CenterID', self.center_id) subproject = db.grep_id_from_lookup_table('title', 'subproject', 'SubprojectID', self.subproject_id) project = db.grep_id_from_lookup_table('Name', 'Project', 'ProjectID', self.project_id)