Skip to content

Insertion of scans in table mri_protocol_violated_scans fail #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/scripts_md/MRI.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ INPUTS:

RETURNS: textual name of scan type from the `mri_scan_type` table

### insert\_violated\_scans($dbhr, $series\_desc, $minc\_location, $patient\_name, $candid, $pscid, $visit, $tr, $te, $ti, $slice\_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $echo\_numbers, $phase\_enc\_dir, $data\_dir, $mriProtocolGroupID)
### insert\_violated\_scans($db, $series\_desc, $minc\_location, $patient\_name, $candidateID, $pscid, $visit, $tr, $te, $ti, $slice\_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $echo\_numbers, $phase\_enc\_dir, $data\_dir, $mriProtocolGroupID)

Inserts scans that do not correspond to any of the defined protocol from the
`mri_protocol` table into the `mri_protocol_violated_scans` table of the
Expand All @@ -98,7 +98,7 @@ INPUTS:
- $series\_desc : series description of the scan
- $minc\_location : location of the MINC file
- $patient\_name : patient name of the scan
- $candid : candidate's `CandID`
- $candidateID : candidate's `ID`
- $pscid : candidate's `PSCID`
- $visit : visit of the scan
- $tr : repetition time of the scan
Expand Down
14 changes: 9 additions & 5 deletions uploadNeuroDB/NeuroDB/MRI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,16 @@ sub identify_scan_db {
} # if(keys %mriProtocolGroupIDs > 1)...else...
} # if (@rows==0)....else...

$query = "SELECT ID FROM candidate WHERE CandID=?";
my $rowsref = $$dbhr->selectall_arrayref($query, { Slice=> {} }, $candid);
my $candidateID = $rowsRef->[0]->{'ID'};

# if we got here, we're really clueless: insert scan in mri_protocol_violated_scans
# table. Note that $mriProtocolGroupID will be undef unless exactly one protocol
# group was used to try to identify the scan
insert_violated_scans(
$db, $series_description, $minc_location, $patient_name,
$candid, $pscid, $tr, $te,
$candidateID, $pscid, $tr, $te,
$ti, $slice_thickness, $xstep, $ystep,
$zstep, $xspace, $yspace, $zspace,
$time, $seriesUID, $tarchiveID, $image_type,
Expand All @@ -524,7 +528,7 @@ sub identify_scan_db {

=pod

=head3 insert_violated_scans($dbhr, $series_desc, $minc_location, $patient_name, $candid, $pscid, $visit, $tr, $te, $ti, $slice_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $echo_numbers, $phase_enc_dir, $data_dir, $mriProtocolGroupID)
=head3 insert_violated_scans($db, $series_desc, $minc_location, $patient_name, $candidateID, $pscid, $visit, $tr, $te, $ti, $slice_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $echo_numbers, $phase_enc_dir, $data_dir, $mriProtocolGroupID)

Inserts scans that do not correspond to any of the defined protocol from the
C<mri_protocol> table into the C<mri_protocol_violated_scans> table of the
Expand All @@ -535,7 +539,7 @@ INPUTS:
- $series_desc : series description of the scan
- $minc_location : location of the MINC file
- $patient_name : patient name of the scan
- $candid : candidate's C<CandID>
- $candidateID : candidate's C<ID>
- $pscid : candidate's C<PSCID>
- $visit : visit of the scan
- $tr : repetition time of the scan
Expand All @@ -562,7 +566,7 @@ INPUTS:
sub insert_violated_scans {

my ($db, $series_description, $minc_location, $patient_name,
$candid, $pscid, $tr, $te,
$candidateID, $pscid, $tr, $te,
$ti, $slice_thickness, $xstep, $ystep,
$zstep, $xspace, $yspace, $zspace,
$time, $seriesUID, $tarchiveID, $image_type,
Expand All @@ -577,7 +581,7 @@ sub insert_violated_scans {
my $time_run = sprintf("%4d-%02d-%02d %02d:%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec);

my %newMriProtocolViolatedScans = (
'CandID' => $candid,
'CandidateID' => $candidateID,
'PSCID' => $pscid,
'TarchiveID' => $tarchiveID,
'time_run' => $time_run,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use File::Basename;
use TryCatch;

my @MRIPROTOCOLVIOLATEDSCANS_FIELDS = qw(
ID CandID PSCID TarchiveID time_run series_description minc_location
ID CandidateID PSCID TarchiveID time_run series_description minc_location
PatientName TR_range TE_range TI_range slice_thickness_range
xspace_range yspace_range zspace_range xstep_range ystep_range zstep_range
time_range SeriesUID image_type PhaseEncodingDirection EchoNumber
Expand Down Expand Up @@ -201,4 +201,4 @@ License: GPLv3
LORIS community <loris.info@mcin.ca> and McGill Centre for Integrative
Neuroscience

=cut
=cut
Loading