CoNNECT 0.1 documentation
Several custom support tools have been created to aid in the batch processing. These tools support parallel processing via HTCondor and SGE implemented in the custom batch processing described in the previous section.
Note
FIGURE TO BE INSERTED
Create a BIDS-compliant filename from the specified options.
get_scan_id(subject=SUBJECT, session=SESSION, task=TASK, acquisition=ACQUISITION, run=RUN, process=PROCESS, resolution=RESOLUTION, space=SPACE, description=DESCRIPTION, suffix=SUFFIX, extension=EXTENSION)
subject (str) – Optional subject identifier
session (str) – Optional session identifier
task (str) – Optional BIDS description (task-ABC)
acquisition (str) – BIDS description (acq-ABC)
run (str) – Optional BIDS description (run-ABC)
process (str) – Optional BIDS description (proc-ABC)
resolution (str) – Optional BIDS description (res-ABC)
space (str) – Optional BIDS description (space-ABC)
description (str) – Optional BIDS description (desc-ABC)
suffix (str) – Optional BIDS suffix
extension (str) – Optional filename extension (do not begin with ‘.’)
Error – Any error occurs.
BIDS compliant filename string
Creates an HTCondor job for FSL commands.
create_fsl_condor_job(jobName, exeName, machineNames, submit, error, output, log, dagman)
jobName (str) – Required name for the parallel htcondor job
exeName (str) – FSL executable name
machineNames (list[str]) – list of machine names to execute jobs
submit (str) – fullpath to output submit file
error (str) – fullpath to output submit file
output (str) – fullpath to output submit file
log (str) – fullpath to output submit file
dagman (str) – Pycondor Dagman object
Error – any encountered error
pycondor Job object
pycondor.Job
Creates an HTCondor job for helper_function commands.
create_python_condor_job(jobName, exeName, machineNames, submit, error, output, log, dagman)
jobName (str) – Required name for the parallel htcondor job
exeName (str) – FSL executable name
machineNames (list[str]) – list of machine names to execute jobs
submit (str) – fullpath to output submit file
error (str) – fullpath to output submit file
output (str) – fullpath to output submit file
log (str) – fullpath to output submit file
dagman (str) – Pycondor Dagman object
Error – any encountered error
pycondor Job object
pycondor.Job
This support tool implements volume extraction (for 4D datasets), brain extraction, and/or registration via FSL’s FLIRT. Specifically, this tools supports paralleled computation implemented from connect_flirt. A flowchart showing the order of operations is depicted in Fig. 13.
Note
NEED TO PROVIDE A REFERENCE TO CONNECT_FLIRT.py
See also
This support tool requires JSON control files to specify input parameters for FLIRT and any additional processing such as volume extraction and brain extraction.
This function performed FLIRT registration between secondary and/or standard (reference) images. Brain extraction will be performed prior to registration on the input file if bet_params is specified.
flirt(IN_FILE,DATA_DIR,FLIRT_PARAMS,overwrite=False,bet_params=None,progress=False)
IN_FILE (str or None or Pathlike object) – REQUIRED String or pathlike object to an input NIfTI file.
DATA_DIR (str or None or Pathlike object) – REQUIRED String or pathlike object to the project’s data directory (project’s ‘dataDir’ credential)
FLIRT_PARAMS (str or None or Pathlike object) – REQUIRED String or pathlike object to the input file’s FLIRT parameter file
overwrite (bool) – OPTIONAL overwrite any existing files (default False)
bet_params (str or None or Pathlike object) – OPTIONAL String or pathlike object to the input file’s BET parameter file (default None)
progress (bool) – OPTIONAL operate in verbose mode (default False)
Error – If path does not exist.
None
None
flirt.py also supports execution via command-line:
$ ./flirt.py <IN_FILE> <DATA_DIR> <FLIRT_PARAMS> --overwrite --bet-params <BET_PARAMS> --progress
Creates a registration overlay image (PNG). This tool is utilized by flirt.py.
Top row contains a background image of IN_FILE in REF_FILE space overlaid with the edges of REF_FILE (in red). Bottom row contains a background image of REF_FILE overlaid with the edges of IN_FILE in REF_FILE space (in red).
flirt_pngappend(IN_FILE, IN_FILE, OUT_FILE)
IN_FILE (str or None or Pathlike object) – REQUIRED String or pathlike object to an input NIfTI file transformed to the space of REF_FILE.
REF_FILE (str or None or Pathlike object) – REQUIRED String or pathlike object to a reference NIfTI file.
OUT_FILE (str or None or Pathlike object) – REQUIRED String or pathlike object to the output PNG file that will be created
Error – If any error occurs.
None
None
This function is currently used by connect_create_raw_nii.py.
Search the metadata accompanying a sourcedata NIfTI file (found in the accompanying JSON sidecar) using the Project’s scan_id JSON file within the Project’s ‘code’ directory (found Scan Identification).
get_scan_id(inDir, basename)
Error – Any error occurs.
scan name created from get_bids_filename found in bids_commands.py, bids directory as identified in the Project’s scan_id JSON file within the Project’s ‘code’ directory
Get metadata from a MRS file.
This program returns the Project credentials into the custom specBase class (NEEDS REFERENCE), which should be imported prior to calling get_spec_base().
get_spec_base(specFile)
specFile (str) – Required path to a MRS file
Error – Any error occurs
None
None
Performs a query of the identified table and returns multiple columns that matched the search criteria.
Performs a query into the Project’s searchTable’s ‘fullpath’ column using the search criteria identified for a single file. Returns a single filepath.
query_file(regexStr, database=’CoNNECT’, searchtable=None, returncol=’fullpath’, searchcol=’filename’, progress=False, orderby=’fullpath’, inclusion=None, exclusion=None, orinclusion=None)
regexStr (str) – Required initial search terms
returncol (str) – Optional table column to return (default ‘fullpath’)
progress (bool) – Optional operate in verbose mode
orderby (str) – Optional column to sort results (default ‘fullpath’)
inclusion (str or list[str]) – Optional inclusion criteria to refine results. These must also be contained within searchcol (AND operation)
exclusion (str or list[str]) – Optional exclusion criteria to refine results. These must not be within the searchcol
orinclusion (str or list[str]) – Optional inclusion criteria to refine results. These may also be contained within the search column (OR operation)
Error – Any error occurs
Fullpath to a single file if only 1 file matches the search criteria, otherwise None.
None or str
Performs a query into the Project’s searchSourceTable’s ‘fullpath’ column using the search criteria identified for a single file. Returns a single filepath.
query_source_file(regexStr, database=’CoNNECT’, searchtable=None, returncol=’fullpath’, searchcol=’filename’, progress=False, orderby=’fullpath’, inclusion=None, exclusion=None, orinclusion=None)
regexStr (str) – Required initial search terms
returncol (str) – Optional table column to return (default ‘fullpath’)
progress (bool) – Optional operate in verbose mode
orderby (str) – Optional column to sort results (default ‘fullpath’)
inclusion (str or list[str]) – Optional inclusion criteria to refine results. These must also be contained within searchcol (AND operation)
exclusion (str or list[str]) – Optional exclusion criteria to refine results. These must not be within the searchcol
orinclusion (str or list[str]) – Optional inclusion criteria to refine results. These may also be contained within the search column (OR operation)
Error – Any error occurs
Fullpath to a single sourcedata file if only 1 file matches the search criteria, otherwise None.
None or str
Queries a directory for existing NIfTI images.
sql_query_dirs(regexStr, dirToCheck, showProgress)
Performs a query into the provided table/column using the search criteria identified. Returns unique directories containing the identified files.
sql_query_dirs(regexStr, showProgress, rawFlag, inclusion=None, exclusion=None)
regexStr (str) – Required search string
showProgress (bool) – Required verbose mode
rawFlag (bool) – Required true for project’s searchSourceTable (default false - project’s searchTable)
inclusion (str or list[str]) – Optional inclusion criteria to refine results. These must also be contained within searchcol (AND operation)
exclusion (str or list[str]) – Optional exclusion criteria to refine results. These must not be within the searchcol
Error – Any error occurs
The list of directories containing files matching search criteria
Performs a query into the provided table/column using the search criteria identified.
sql_query(database=’CoNNECT’, searchtable=None, returncol=’fullpath’, searchcol=’filename’, regex=None, progress=False, orderby=’fullpath’, inclusion=None, exclusion=None, orinclusion=None)
database (str) – Optional MySQL database containing the project’s searchtable (default ‘CoNNECT’)
searchtable (str) – Required MySQL table to query
returncol (str) – Optional table column to return (default ‘fullpath’)
searchcol (str) – Optional table column to query (default ‘filepath’)
regex (str) – Required initial search terms
progress (bool) – Optional operate in verbose mode
orderby (str) – Optional column to sort results (default ‘fullpath’)
inclusion (str or list[str]) – Optional inclusion criteria to refine results. These must also be contained within searchcol (AND operation)
exclusion (str or list[str]) – Optional exclusion criteria to refine results. These must not be within the searchcol
orinclusion (str or list[str]) – Optional inclusion criteria to refine results. These may also be contained within the search column (OR operation)
Error – Any error occurs
The list of columns matching search criteria
Performs a query into the provided table/column using the search criteria identified.
sql_multiple_query(database=’CoNNECT’, searchtable=None, returncol=’fullpath’, searchcol=’filename’, regex=None, progress=False, orderby=’fullpath’)
database (str) – Optional MySQL database containing the project’s searchtable (default ‘CoNNECT’)
searchtable (str) – Required MySQL table to query
returncol (str) – Optional table column to return (default ‘fullpath’)
searchcol (str) – Optional table column to query (default ‘filepath’)
regex (str) – Required initial search terms
progress (bool) – Optional operate in verbose mode
orderby (str) – Optional column to sort results (default ‘fullpath’)
Error – Any error occurs
All the columns elements from each row where the input column matches the search criteria
Creates the tables for a project whose credentials have been loaded into custom creds class via read_credentials().
sql_create_project_tables(progress=False)
progress (bool) – Optional operate in verbose mode
Error – Any error occurs
None
None
Inserts items into a Project’s table. The project’s credentials must have been loaded into customcreds class via read_credentials().
sql_table_insert(table,item,progress=False)
Removes items into a Project’s table. The project’s credentials must have been loaded into customcreds class via read_credentials().
sql_table_remove(table,item,progress=False)
Creates a connection to the MySQL database.
sql_create_mysql_connection(host_name, user_name, user_password, db_name, progress)
Error – Any error occurs
Pymysql connect object
pymysql.connect
Data collected and produced for each project will follow BIDS specifications to ensure community standards are upheld, to improve data integrity and conformity, and to improve data consistency and data processing optimization.
A single JSON file describes various parameters for each project/program. This file is ‘credentials.json’ and is located in the main code directory on the mounted centralized storage (/resshare/general_processing_codes). The table below outlines the keys and their associated descriptions for a project in the credentials file. Each project in the credentials file should be defined as their own key titled by their respective protocol number prescribed by their IRB of record. For pilot studies, a short name may be used in place of the IRB number.
Key |
Data Type |
Description |
---|---|---|
projects |
list[string] |
List of all project identifiers (these are referred to as <project_identifier>) |
<project_identifier> |
dictionary |
Dictionary identifying key elements of each project described in |
Key |
Data Type |
Description |
---|---|---|
description |
string |
Text used to give a short description of the project |
title |
string |
Full project title |
database |
string |
MySQL database for the associated main and source tables described in the MySQL section of this document |
dataDir |
string |
Local directory within the mounted centralized storage’s ‘projects’ folder where data shall be located. |
dicom_id |
string |
Unique string within the DICOM filenames to help identify DICOMS within the PACS and souredata directories |
searchSourceTable |
string |
MySQL table identifying files within the project’s sourcedata directory |
searchTable |
string |
MySQL table identifying files within the project’s directory (excluding sourcedata) |
Read the credential file (credentials.json) from the general_processing_codes directory.
This program returns the Project credentials into the custom creds class (NEEDS REFERENCE), which should be imported prior to calling read_credentials()
read_credentials(project)
project (string) – <project_identifier>. This should correspond to the projects IRB protocol number.
Error – if credentials.json is not found
None
None