Skip to content

Commit

Permalink
Update the bids_import script logic to explicitely add the --no-copy …
Browse files Browse the repository at this point in the history
…option
  • Loading branch information
laemtl committed Mar 12, 2024
1 parent a12d199 commit bfd5834
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
13 changes: 7 additions & 6 deletions python/bids_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def main():
nocopy = False

long_options = [
"help", "profile=", "directory=",
"createcandidate", "createsession", "idsvalidation", "nobidsvalidation", "type=", "verbose"
"help", "profile=", "directory=",
"createcandidate", "createsession", "idsvalidation",
"nobidsvalidation", "nocopy", "type=",
"verbose"
]
usage = (
'\n'
Expand All @@ -51,6 +53,7 @@ def main():
'\t-s, --createsession : to create BIDS sessions in LORIS (optional)\n'
'\t-i, --idsvalidation : to validate BIDS directory for a matching pscid/candid pair (optional)\n'
'\t-b, --nobidsvalidation : to disable BIDS validation for BIDS compliance\n'
'\t-a, --nocopy : to disable dataset copy in data assembly_bids\n'
'\t-t, --type : raw | derivatives. Specify the dataset type.'
'If not set, the pipeline will look for both raw and derivatives files.\n'
'Required if no dataset_description.json is found.\n'
Expand Down Expand Up @@ -81,6 +84,8 @@ def main():
idsvalidation = True
elif opt in ('-n', '--nobidsvalidation'):
nobidsvalidation = True
elif opt in ('-a', '--nocopy'):
nocopy = True
elif opt in ('-t', '--type'):
type = arg

Expand All @@ -107,10 +112,6 @@ def main():
# making sure that there is a final / in data_dir
data_dir = data_dir if data_dir.endswith('/') else data_dir + "/"

assembly_bids_path = os.path.join(data_dir, 'assembly_bids')
if bids_dir.strip('/').startswith(assembly_bids_path.strip('/')):
nocopy = True

# read and insert BIDS data
read_and_insert_bids(
bids_dir,
Expand Down
9 changes: 7 additions & 2 deletions python/extract_eeg_bids_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():
" EXTRACT EEG ARCHIVES\n"
"********************************************************************\n"
"The program gets an archive associated with an upload ID, extract it and push its content "
"to EEGS3DataPath, an Amazon S3 bucket or {dataDirBasepath}/assembly_bids.\n\n"
"to EEGS3DataPath, an Amazon S3 bucket or EEGAssemblyBIDS.\n\n"

"usage : extract_eeg_bids_archive.py -p <profile> -u <upload_id> ...\n\n"

Expand Down Expand Up @@ -214,7 +214,12 @@ def main():
)
error = True
else:
data_eeg_modality_path = os.path.join(data_dir, 'assembly_bids', eeg_session_rel_path, modality)
assembly_bids_path = config_db_obj.get_config("EEGAssemblyBIDS")
if not assembly_bids_path:
data_dir = config_db_obj.get_config("dataDirBasepath")
assembly_bids_path = os.path.join(data_dir, 'assembly_bids')

data_eeg_modality_path = os.path.join(assembly_bids_path, eeg_session_rel_path, modality)

"""
If the suject/session/modality BIDS data already exists
Expand Down
9 changes: 6 additions & 3 deletions python/ingest_eeg_bids_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def main():
# Get tmp dir from loris_getopt object
# and create the log object (their basename being the name of the script run)
# ---------------------------------------------------------------------------------------------
data_dir = config_db_obj.get_config("dataDirBasepath")
assembly_bids_path = os.path.join(data_dir, 'assembly_bids')
assembly_bids_path = config_db_obj.get_config("EEGAssemblyBIDS")
if not assembly_bids_path:
data_dir = config_db_obj.get_config("dataDirBasepath")
assembly_bids_path = os.path.join(data_dir, 'assembly_bids')

# ---------------------------------------------------------------------------------------------
# Get all EEG upload with status = Extracted
Expand Down Expand Up @@ -145,8 +147,9 @@ def main():
continue

script = os.environ['LORIS_MRI'] + '/python/bids_import.py'
# Assume eeg and raw data for now
eeg_path = os.path.join(path, 'eeg')
command = 'python ' + script + ' -p ' + profile + ' -d ' + eeg_path + ' --nobidsvalidation --type raw'
command = 'python ' + script + ' -p ' + profile + ' -d ' + eeg_path + ' --nobidsvalidation --nocopy --type raw'

try:
result = subprocess.run(command, shell = True, capture_output=True)
Expand Down

0 comments on commit bfd5834

Please sign in to comment.