Skip to content

Commit

Permalink
rename field
Browse files Browse the repository at this point in the history
  • Loading branch information
maximemulder committed Sep 26, 2024
1 parent 182ae25 commit 0cf332b
Show file tree
Hide file tree
Showing 25 changed files with 1,053 additions and 1,063 deletions.
216 changes: 108 additions & 108 deletions DTIPrep/DTIPrepRegister.pl

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions docs/02-Install.md

Large diffs are not rendered by default.

344 changes: 172 additions & 172 deletions docs/03-TechnicalInfrastructure.md

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions docs/scripts_md/GetRole.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ NeuroDB::objectBroker::GetRole -- A role for basic SELECT operations on the data
# DESCRIPTION

This class provides methods used to accomplish basic `SELECT` operations on the database.
It allows the retrieval of records using a simple `WHERE` clause of the form
It allows the retrieval of records using a simple `WHERE` clause of the form
`WHERE constraint_1 AND constraint_2 AND ... AND constraint_n`.
Subparts of the `WHERE` clause can only be combined with `AND` (`OR` is not supported).
Each subpart of the `WHERE` clause specifies that a field must be either equal to a given
value, not equal to a given value, NULL or NOT NULL.
Subparts of the `WHERE` clause can only be combined with `AND` (`OR` is not supported).
Each subpart of the `WHERE` clause specifies that a field must be either equal to a given
value, not equal to a given value, NULL or NOT NULL.

Classes using this role must implement methods `getColumnNames()`, `getTableName()` and `db()`.

Expand All @@ -20,7 +20,7 @@ Classes using this role must implement methods `getColumnNames()`, `getTableName
### get($isCount, $columnValuesRef)

Fetches the records in the table whose name is returned by method `getTableName()` that satisfy
specific constraints.
specific constraints.

Note that this method is private.

Expand All @@ -31,21 +31,21 @@ INPUTS:
should have in order to be part of the result set (key: column name, value: column
value).

RETURNS:
RETURNS:
- a reference to an array of hash references. Every hash contains the values
for a given row returned by the method call: the key/value pairs contain
the name of a column (see `@MRI_SCAN_TYPE_FIELDS`) and the value it
the name of a column (see `@MRI_SCAN_TYPE_FIELDS`) and the value it
holds, respectively. As an example, suppose array `$r` contains the result of a
given call to this function. One would fetch the `Scan_type` of the 2nd record
returned using `$r->[1]->{'Scan_type'}`.
given call to this function. One would fetch the `MriScanTypeName` of the 2nd record
returned using `$r->[1]->{'MriScanTypeName'}`.
If the method is called with `$isCount` set to true, then it will return
a reference to an array containing a single hash reference, its unique key being
a reference to an array containing a single hash reference, its unique key being
`'COUNT(*)'` with the associated value set to the selected count.

### addWhereEquals($columnValuesRef, $k, $whereRef, $valsRef)

Gets the string representation of a constraint of the form `field=value` and adds it
to the current set of `WHERE` clauses. Note that constraints specifying that a field
to the current set of `WHERE` clauses. Note that constraints specifying that a field
must be NULL will be properly translated to `field IS NULL` (not `field=NULL`).

INPUTS:
Expand All @@ -55,13 +55,13 @@ INPUTS:
- Reference on the array of values each field in `$columnValuesRef` must be
equal or not equal to.

RETURNS:
RETURNS:
- Nothing (adds an element to `@$whereRef`).

### addWhereFunction($columnValuesRef, $k, $whereRef, $valsRef)

Gets the string representation of a constraint that uses an SQL function or operator.
Currently, only the operator `NOT` (i.e. field `NOT` equal to a given value or `NOT NULL`) is
Currently, only the operator `NOT` (i.e. field `NOT` equal to a given value or `NOT NULL`) is
supported.

INPUTS:
Expand All @@ -71,13 +71,13 @@ INPUTS:
- Reference on the array of values each field in `$columnValuesRef` must be
equal or not equal to.

RETURNS:
RETURNS:
- Nothing. Updates arrays `@$whereRef` (and `@$valsRef` if necessary).

### addWhereNotEquals($columnValuesRef, $k, $whereRef, $valsRef)

Gets the string representation of a constraint of the form `field != value` and adds it to
the current set of `WHERE` clauses. Note that constraints specifying that a field must not be NULL
the current set of `WHERE` clauses. Note that constraints specifying that a field must not be NULL
will be properly translated to `field IS NOT NULL` (not `field!=NULL`).

INPUTS:
Expand All @@ -87,13 +87,13 @@ INPUTS:
- Reference on the array of values each field in `$columnValuesRef` must be
equal or not equal to.

RETURNS:
RETURNS:
- Nothing. Updates arrays `@$whereRef` (and `@$valsRef` if necessary).

### get($columnValuesRef)

Fetches the records in the table whose name is returned by method `getTableName()` that satisfy
specific constraints.
specific constraints.

INPUTS:
- reference to a hash array that contains the constraints on the column values that the records
Expand All @@ -102,25 +102,25 @@ INPUTS:
a single value or a reference to a hash (this hash describes a constraint involving an
SQL function or operator other than '='). Examples of a valid set of constraints:

{
{
Field1 => 'Value1',
Field2 => { NOT => 3 },
Field3 => undef
}


RETURNS:

RETURNS:
- a reference to an array of hash references. Every hash contains the values
for a given row returned by the method call: the key/value pairs contain
the name of a column (as listed by `getColumnNames()`) and the value it
the name of a column (as listed by `getColumnNames()`) and the value it
holds, respectively. As an example, suppose array `$r` contains the result of a
given call to this function. One would fetch the `Scan_type` of the 2nd record
returned using `$r->[1]->{'Scan_type'}`.
given call to this function. One would fetch the `MriScanTypeName` of the 2nd record
returned using `$r->[1]->{'MriScanTypeName'}`.

### getCount($columnValuesRef)

Fetches the number of records in the table whose name is returned by method `getTableName()`
that satisfy specific constraints.
Fetches the number of records in the table whose name is returned by method `getTableName()`
that satisfy specific constraints.

INPUTS:
- reference to a hash array that contains the constraints on the column values that the records
Expand All @@ -129,12 +129,12 @@ INPUTS:
a single value or a reference to a hash (this hash describes a constraint involving an
SQL function or operator other than '='). Examples of a valid set of constraints:

{
{
Field1 => 'Value1',
Field2 => { NOT => 3 },
Field3 => undef
}


RETURNS:

RETURNS:
- the number of records found.
8 changes: 4 additions & 4 deletions docs/scripts_md/MriScanTypeOB.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ INPUTS:

RETURNS: a reference to an array of hash references. Every hash contains the values
for a given row returned by the method call: the key/value pairs contain
the name of a column (see `@MRI_SCAN_TYPE_FIELDS`) and the value it
the name of a column (see `@MRI_SCAN_TYPE_FIELDS`) and the value it
holds, respectively. As an example, suppose array `$r` contains the result of a
given call to this function. One would fetch the `Scan_type` of the 2nd record
returned using `$r-`\[1\]->{'Scan\_type'}>.
given call to this function. One would fetch the `MriScanTypeName` of the 2nd record
returned using `$r-`\[1\]->{'MriScanTypeName'}>.
If the method is called with `$isCount` set to true, then it will return
a reference to an array containing a single hash reference, its unique key being
a reference to an array containing a single hash reference, its unique key being
`'COUNT(*)'` with the associated value set to the selected count.

# TO DO
Expand Down
50 changes: 25 additions & 25 deletions docs/scripts_md/minc_to_bids_converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,30 @@ RETURNS:

{
"1" => {
'fileID' => 'FileID value',
'file' => 'file path',
'echoTime' => 'Echo Time of the file',
'AcquisitionProtocolID' => 'Scan type ID',
'candID' => 'Candidate CandID',
'sessionID' => 'Session ID',
'visitLabel' => 'Visit Label',
'echoNumber' => 'Echo Number of the scan',
'seriesNumber' => 'Series Number of the scan',
'imageType' => 'Image Type',
'lorisScanType' => 'LORIS Scan Type name'
'fileID' => 'FileID value',
'file' => 'file path',
'echoTime' => 'Echo Time of the file',
'MriScanTypeID' => 'Scan type ID',
'candID' => 'Candidate CandID',
'sessionID' => 'Session ID',
'visitLabel' => 'Visit Label',
'echoNumber' => 'Echo Number of the scan',
'seriesNumber' => 'Series Number of the scan',
'imageType' => 'Image Type',
'lorisScanType' => 'LORIS Scan Type name'
},
"2" => {
'fileID' => 'FileID value',
'file' => 'file path',
'echoTime' => 'Echo Time of the file',
'AcquisitionProtocolID' => 'Scan type ID',
'candID' => 'Candidate CandID',
'sessionID' => 'Session ID',
'visitLabel' => 'Visit Label',
'echoNumber' => 'Echo Number of the scan',
'seriesNumber' => 'Series Number of the scan',
'imageType' => 'Image Type',
'lorisScanType' => 'LORIS Scan Type name'
'fileID' => 'FileID value',
'file' => 'file path',
'echoTime' => 'Echo Time of the file',
'MriScanTypeID' => 'Scan type ID',
'candID' => 'Candidate CandID',
'sessionID' => 'Session ID',
'visitLabel' => 'Visit Label',
'echoNumber' => 'Echo Number of the scan',
'seriesNumber' => 'Series Number of the scan',
'imageType' => 'Image Type',
'lorisScanType' => 'LORIS Scan Type name'
}
...
}
Expand Down Expand Up @@ -162,7 +162,7 @@ OUTPUT:
'BIDSCategoryName' => 'BIDS category to use for the NIfTI file, aka anat, func, fmap, dwi...',
'BIDSScanTypeSubCategory' => 'BIDS subcategory to use for the NIfTI file, aka task-rest, task-memory...',
'BIDSEchoNumber' => 'Echo Number associated with the NIfTI file',
'Scan_type' => 'label of the LORIS Scan type from the mri_scan_type table'
'ScanType' => 'label of the LORIS Scan type from the mri_scan_type table'
}

Note: BIDSEchoNumber and BIDSScanTypeSubCategory can be null for a given NIfTI file.
Expand Down Expand Up @@ -371,14 +371,14 @@ OUTPUT:

### grep\_acquisitionProtocolID\_from\_BIDS\_scan\_type($db\_handle, $bids\_scan\_type)

Greps the AcquisitionProtocolID associated to a BIDS magnitude file in the database.
Greps the MriScanTypeID associated to a BIDS magnitude file in the database.

INPUTS:
- $db\_handle : database handle
- $bids\_scan\_type: name of the BIDS scan type (for example: magnitude)

OUTPUT:
- AcquisitionProtocolID associated to the BIDS scan type file in the database
- MriScanTypeID associated to the BIDS scan type file in the database

### create\_BIDS\_magnitude\_files($phasediff\_filename, $magnitude\_files\_hash)

Expand Down
2 changes: 1 addition & 1 deletion docs/scripts_md/register_processed_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ RETURNS: scanner ID

### getAcqProtID($scanType, $dbh)

This function returns the `AcquisitionProtocolID` of the file to register in
This function returns the `MriScanTypeID` of the file to register in
the database based on `scanType` in the `mri_scan_type` table.

INPUTS:
Expand Down
12 changes: 6 additions & 6 deletions python/lib/database_lib/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ def update_files(self, file_id, fields, values):

def select_distinct_acquisition_protocol_id_per_tarchive_source(self, tarchive_id):
"""
Get a list of distinct scan types (a.k.a. `AcquisitionProtocolID`) inserted into the `files`
Get a list of distinct scan types (a.k.a. `MriScanTypeID`) inserted into the `files`
table for a given DICOM archive (a.k.a. `TarchiveSource`).
:param tarchive_id: `TarchiveID` to use as the `TarchiveSource` to restrict the SELECT statement on
:type tarchive_id: int
:return: list of scan types found (`AcquisitionProtocolID`)
:return: list of scan types found (`MriScanTypeID`)
:rtype: list
"""

query = "SELECT DISTINCT AcquisitionProtocolID FROM files WHERE TarchiveSource = %s"
query = "SELECT DISTINCT MriScanTypeID FROM files WHERE TarchiveSource = %s"

results = self.db.pselect(query=query, args=(tarchive_id,))
acquisition_protocol_id_list = [v["AcquisitionProtocolID"] for v in results]
acquisition_protocol_id_list = [v["MriScanTypeID"] for v in results]

return acquisition_protocol_id_list

Expand All @@ -166,15 +166,15 @@ def get_file_ids_and_series_number_per_scan_type_and_tarchive_id(self, tarchive_
:param scan_type_id: ID of the scan type to restrict the query on
:type scan_type_id: int
:return: list of `FileID` and `SeriesNumber` for a given `TarchiveID` and `AcquisitionProtocolID`
:return: list of `FileID` and `SeriesNumber` for a given `TarchiveID` and `MriScanTypeID`
:rtype: list
"""

query = "SELECT FileID, Value AS SeriesNumber " \
"FROM files " \
" JOIN parameter_file USING(FileID) " \
" JOIN parameter_type USING(ParameterTypeID) " \
"WHERE TarchiveSource = %s AND AcquisitionProtocolID = %s AND Name = %s"
"WHERE TarchiveSource = %s AND MriScanTypeID = %s AND Name = %s"

return self.db.pselect(query=query, args=(tarchive_id, scan_type_id, "series_number"))

Expand Down
6 changes: 3 additions & 3 deletions python/lib/database_lib/mri_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ def get_bids_info_for_scan_type_id(self, scan_type_id):
bids_scan_type.BIDSScanType,
bmstr.BIDSEchoNumber,
bids_phase_encoding_direction.BIDSPhaseEncodingDirectionName,
mst.Scan_type
mst.MriScanTypeName AS ScanType
FROM bids_mri_scan_type_rel bmstr
JOIN mri_scan_type mst ON mst.ID = bmstr.MRIScanTypeID
JOIN mri_scan_type mst ON mst.MriScanTypeID = bmstr.MRIScanTypeID
JOIN bids_category USING (BIDSCategoryID)
JOIN bids_scan_type USING (BIDSScanTypeID)
LEFT JOIN bids_scan_type_subcategory USING (BIDSScanTypeSubCategoryID)
LEFT JOIN bids_phase_encoding_direction USING (BIDSPhaseEncodingDirectionID)
WHERE
mst.ID = %s
mst.MriScanTypeID = %s
"""

results = self.db.pselect(query=query, args=(scan_type_id,))
Expand Down
2 changes: 1 addition & 1 deletion python/lib/database_lib/mri_protocol_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_list_of_possible_protocols_based_on_session_info(

query = "SELECT * FROM mri_protocol_checks" \
" JOIN mri_protocol_checks_group_target mpcgt USING (MriProtocolChecksGroupID)" \
" WHERE Scan_type = %s "
" WHERE MriScanTypeID = %s "

query += " AND (mpcgt.ProjectID IS NULL OR mpcgt.ProjectID = %s)" \
if project_id else " AND mpcgt.ProjectID IS NULL"
Expand Down
8 changes: 4 additions & 4 deletions python/lib/database_lib/mri_scan_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def get_scan_type_name_from_id(self, scan_type_id):
"""

results = self.db.pselect(
query='SELECT Scan_type FROM mri_scan_type WHERE ID = %s',
query='SELECT MriScanTypeName FROM mri_scan_type WHERE MriScanTypeID = %s',
args=(scan_type_id,)
)

return results[0]['Scan_type'] if results else None
return results[0]['MriScanTypeName'] if results else None

def get_scan_type_id_from_name(self, scan_type_name):
"""
Expand All @@ -65,8 +65,8 @@ def get_scan_type_id_from_name(self, scan_type_name):
"""

results = self.db.pselect(
query='SELECT ID FROM mri_scan_type WHERE Scan_type = %s',
query='SELECT MriScanTypeID FROM mri_scan_type WHERE MriScanTypeName = %s',
args=(scan_type_name,)
)

return results[0]['ID'] if results else None
return results[0]['MriScanTypeID'] if results else None
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def _register_violations_log(self, violations_list, file_rel_path):
'PatientName': self.subject_id_dict['PatientName'],
'CandID': self.subject_id_dict['CandID'],
'Visit_label': self.subject_id_dict['visitLabel'],
'Scan_type': self.scan_type_id,
'MriScanTypeID': self.scan_type_id,
'EchoTime': scan_param['EchoTime'] if 'EchoTime' in scan_param.keys() else None,
'EchoNumber': scan_param['EchoNumber'] if 'EchoNumber' in scan_param.keys() else None,
'PhaseEncodingDirection': phase_enc_dir,
Expand Down Expand Up @@ -679,7 +679,7 @@ def _register_into_files_and_parameter_file(self, nifti_rel_path):
'PhaseEncodingDirection': phase_enc_dir,
'CoordinateSpace': 'native',
'OutputType': 'native',
'AcquisitionProtocolID': self.scan_type_id,
'MriScanTypeID': self.scan_type_id,
'FileType': file_type,
'InsertedByUserID': getpass.getuser(),
'InsertTime': datetime.datetime.now().timestamp(),
Expand Down
Loading

0 comments on commit 0cf332b

Please sign in to comment.