diff --git a/docs/scripts_md/MRI.md b/docs/scripts_md/MRI.md index 9c2f943f4..3c3b3bed7 100644 --- a/docs/scripts_md/MRI.md +++ b/docs/scripts_md/MRI.md @@ -74,44 +74,16 @@ RETURNS: the `CandID` or (if none exists) undef ### getSessionID($subjectIDref, $studyDate, $dbhr, $objective, $noStagingCheck) -Gets (or creates) the session ID, given `CandID` and visit label (contained -inside the hash ref `$subjectIDref`). Unless `$noStagingCheck` is true, it -also determines whether staging is required using the `$studyDate` -(formatted YYYYMMDD) to determine whether staging is required based on a -simple algorithm: - -> \- If there exists a session with the same visit label, then that is -> the session ID to use. If any dates (either existing MRI data or -> simply a date of visit) exist associated with that session, then -> if they are outside of some (arbitrary) time window, staging is -> required. If no dates exist, no staging is required. -> -> \- If no sessions exist, then if there is any other date associated -> with another session of the same subject within a time window, -> staging is required. -> -> \- Otherwise, staging is not required. +Gets (or creates) the session ID, given CandID and visitLabel (contained +inside the hashref `$subjectIDref`). INPUTS: - - $subjectIDref : hash reference of subject IDs - - $studyDate : study date - - $dbhr : database handle reference - - $objective : the objective of the study - - $noStagingCheck: a no staging check flag - -RETURNS: a list of two items, (`sessionID`, `requiresStaging`) - -### checkMRIStudyDates($studyDateJD, $dbhr, @fileIDs) - -This method tries to figure out if there may have been labelling problems which -would put the files in a staging area that does not actually exist. - -INPUTS: - - $studyDateJD: study date - - $dbhr : database handle reference - - @fileIDs : array of `fileIDs` to check the study date + - $subjectIDref: hash reference of subject IDs + - $studyDate : study date + - $dbhr : database handle reference + - $objective : the objective of the study -RETURNS: 1 if the file requires staging, 0 otherwise +RETURNS: the session ID of the visit ### getObjective($subjectIDsref, $dbhr) diff --git a/uploadNeuroDB/NeuroDB/MRI.pm b/uploadNeuroDB/NeuroDB/MRI.pm index e00c2af52..671514136 100755 --- a/uploadNeuroDB/NeuroDB/MRI.pm +++ b/uploadNeuroDB/NeuroDB/MRI.pm @@ -193,42 +193,22 @@ sub getScannerCandID { =head3 getSessionID($subjectIDref, $studyDate, $dbhr, $objective, $noStagingCheck) -Gets (or creates) the session ID, given C and visit label (contained -inside the hash ref C<$subjectIDref>). Unless C<$noStagingCheck> is true, it -also determines whether staging is required using the C<$studyDate> -(formatted YYYYMMDD) to determine whether staging is required based on a -simple algorithm: - -=over 3 - -- If there exists a session with the same visit label, then that is - the session ID to use. If any dates (either existing MRI data or - simply a date of visit) exist associated with that session, then - if they are outside of some (arbitrary) time window, staging is - required. If no dates exist, no staging is required. - -- If no sessions exist, then if there is any other date associated - with another session of the same subject within a time window, - staging is required. - -- Otherwise, staging is not required. - -=back +Gets (or creates) the session ID, given CandID and visitLabel (contained +inside the hashref C<$subjectIDref>). INPUTS: - - $subjectIDref : hash reference of subject IDs - - $studyDate : study date - - $dbhr : database handle reference - - $objective : the objective of the study - - $noStagingCheck: a no staging check flag + - $subjectIDref: hash reference of subject IDs + - $studyDate : study date + - $dbhr : database handle reference + - $objective : the objective of the study -RETURNS: a list of two items, (C, C) +RETURNS: the session ID of the visit =cut sub getSessionID { - my ($subjectIDref, $studyDate, $dbhr, $objective, $noStagingCheck) = @_; - my ($sessionID, $requiresStaging, $studyDateJD); + my ($subjectIDref, $studyDate, $dbhr, $objective) = @_; + my ($sessionID, $studyDateJD); my ($query, $sth); my $dbh = $$dbhr; @@ -239,7 +219,6 @@ sub getSessionID { ##### if it finds an existing session it does this: if($sth->rows > 0) { - $requiresStaging = 1 unless $noStagingCheck; my $timepoint = $sth->fetchrow_hashref(); $sessionID = $timepoint->{'ID'}; $sth->finish(); @@ -253,17 +232,10 @@ sub getSessionID { if(defined($studyDate) && $studyDate =~ /^(\d{4})(\d{2})(\d{2})/) { # compute the julian date of the study $studyDateJD = julian_day($1, $2, $3); - } else { - # no study date, so no staging - $requiresStaging = 0; - } - # staging not required if the study date matches the timepoint date of visit - if(defined($studyDateJD) and defined($timepointJD) and $studyDateJD == $timepointJD) { - $requiresStaging = 0; } # check dates of other files - if(defined($studyDateJD) and $requiresStaging == 1) { + if(defined($studyDateJD)) { # get the set of files $query = "SELECT FileID FROM files WHERE SessionID=$sessionID AND FileType='mnc' AND OutputType='native'"; $sth = $dbh->prepare($query); @@ -273,16 +245,13 @@ sub getSessionID { my @files = (); while(my $filehr = $sth->fetchrow_hashref()) { push @files, $filehr->{'FileID'}; } $sth->finish(); - - # run the check - $requiresStaging = checkMRIStudyDates($studyDateJD, $dbhr, @files); + } } ##### if there is no existing session, which always happens if you create candidates based on incoming data } else { - $requiresStaging = 0; - + # determine the visit number and centerID for the next session my $newVisitNo = 0; my $centerID = 0; @@ -329,7 +298,7 @@ sub getSessionID { $subjectIDref->{'visitNo'} = $newVisitNo; # add visit number to subjectIDref # check dates of other files - if(defined($studyDateJD) and !$noStagingCheck) { + if(defined($studyDateJD)) { # get the set of sessions for the subject $query = "SELECT ID FROM session WHERE CandID=$subjectIDref->{'CandID'} AND Active='Y'"; $sth = $dbh->prepare($query); @@ -350,69 +319,14 @@ sub getSessionID { while(my $filearray = $sth->fetchrow_array()) { push @files, $filearray[0]; } $sth->finish(); - - # run the check - note it's backwards (!) because this - # time we're looking for mris in other studies which - # are confounding rather than mris in this study which - # are supporting - $requiresStaging = !checkMRIStudyDates($studyDateJD, $dbhr, @files); } # end if sth->rows (files) } # end if sth->rows (sessionIDs) } # end if defined studyDateJD } - return ($sessionID, $requiresStaging); + return ($sessionID); } -=pod - -=head3 checkMRIStudyDates($studyDateJD, $dbhr, @fileIDs) - -This method tries to figure out if there may have been labelling problems which -would put the files in a staging area that does not actually exist. - -INPUTS: - - $studyDateJD: study date - - $dbhr : database handle reference - - @fileIDs : array of C to check the study date - -RETURNS: 1 if the file requires staging, 0 otherwise - -=cut - -sub checkMRIStudyDates { - my ($studyDateJD, $dbhr, @fileIDs) = @_; - - if(scalar(@fileIDs) == 0) { - carp "No fileIDs passed in to checkMRIStudyDates\n"; - return 0; - } - - my $requiresStaging = 1; - my $file = NeuroDB::File->new($dbhr); - my $studyDateID = $file->getParameterTypeID('study_date'); - - # check the other files - my $query = "SELECT DISTINCT Value FROM parameter_file WHERE ParameterTypeID=$studyDateID AND FileID IN (".join(',', @fileIDs).")"; - my $sth = $${dbhr}->prepare($query); - $sth->execute(); - - if($sth->rows > 0) { - LOOP_FILES: { - while(my $row = $sth->fetchrow_hashref()) { - if($row->{'Value'} =~ /^(\d{4})(\d{2})(\d{2})/) { - my $eventJD = julian_day($1, $2, $3); - if($eventJD == $studyDateJD) { - $requiresStaging = 0; - last LOOP_FILES; - } - } - } # end while - } # end LOOP_FILES - } # end if $sth->rows (parameters) - - return $requiresStaging; -} =pod diff --git a/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm b/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm index 422052820..35d84d14d 100755 --- a/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm +++ b/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm @@ -1577,8 +1577,7 @@ sub setMRISession { $message = "\n==> Getting session ID\n"; $this->{LOG}->print($message); $this->spool($message, 'N', $upload_id, $notify_detailed); - my ($sessionID, $requiresStaging) = - NeuroDB::MRI::getSessionID( + my ($sessionID) = NeuroDB::MRI::getSessionID( $subjectIDsref, $tarchiveInfo->{'DateAcquired'}, $this->{dbhr}, @@ -1587,7 +1586,6 @@ sub setMRISession { $message = "\nSessionID: $sessionID\n"; $this->{LOG}->print($message); $this->spool($message, 'N', $upload_id, $notify_detailed); - # Staging: $requiresStaging\n"; ############################################################ # Make sure MRI Scan Done is set to yes, because now ####### # there is data. ########################################### @@ -1599,7 +1597,7 @@ sub setMRISession { } ${$this->{'dbhr'}}->do($query); } - return ($sessionID, $requiresStaging); + return ($sessionID); } diff --git a/uploadNeuroDB/minc_insertion.pl b/uploadNeuroDB/minc_insertion.pl index d58073830..fdc18fae4 100755 --- a/uploadNeuroDB/minc_insertion.pl +++ b/uploadNeuroDB/minc_insertion.pl @@ -195,8 +195,8 @@ =head2 Methods - Loads the created MINC file and then sets the appropriate parameter for the loaded object (i.e ScannerID, SessionID,SeriesUID, EchoTime, - PendingStaging, CoordinateSpace , OutputType , FileType - ,TarchiveSource and Caveat) + CoordinateSpace , OutputType , FileType, + TarchiveSource and Caveat) - Extracts the correct acquition protocol - Registers the scan into db by first changing the minc-path and setting extra parameters @@ -496,10 +496,9 @@ =head2 Methods } ################################################################ -####### Get the $sessionID and $requiresStaging ################ +####### Get the $sessionID #################################### ################################################################ -my ($sessionID, $requiresStaging) = - NeuroDB::MRI::getSessionID( +my ($sessionID) = NeuroDB::MRI::getSessionID( $subjectIDsref, $tarchiveInfo{'DateAcquired'}, \$dbh, $subjectIDsref->{'subprojectID'} @@ -527,7 +526,6 @@ =head2 Methods $file->setFileData('SessionID', $sessionID); $file->setFileData('SeriesUID', $file->getParameter('series_instance_uid')); $file->setFileData('EchoTime', $file->getParameter('echo_time')); -$file->setFileData('PendingStaging', $requiresStaging); $file->setFileData('CoordinateSpace', 'native'); $file->setFileData('OutputType', 'native'); $file->setFileData('FileType', 'mnc'); diff --git a/uploadNeuroDB/register_processed_data.pl b/uploadNeuroDB/register_processed_data.pl index 8ee4274bd..579512004 100755 --- a/uploadNeuroDB/register_processed_data.pl +++ b/uploadNeuroDB/register_processed_data.pl @@ -256,8 +256,7 @@ =head2 Methods # ----- STEP 4: Determine using sourceFileID: # - subject's identifiers # - sessionID -# - requiresStaging -my ($sessionID,$requiresStaging,$subjectIDsref) = getSessionID($sourceFileID,$dbh); +my ($sessionID,$subjectIDsref) = getSessionID($sourceFileID,$dbh); if (!defined($sessionID)) { print LOG "\nERROR: could not determine sessionID based on sourceFileID " . "$sourceFileID. Are you sure the sourceFile was registered " @@ -388,10 +387,7 @@ sub getSessionID { return undef; } - # set requiresStaging to null as long as don't have any more information on this field - my $requiresStaging = 0; - - return ($sessionID,$requiresStaging,\%subjectIDsref); + return ($sessionID, \%subjectIDsref); } diff --git a/uploadNeuroDB/tarchiveLoader b/uploadNeuroDB/tarchiveLoader index 8aefdc3a6..6068f1e41 100755 --- a/uploadNeuroDB/tarchiveLoader +++ b/uploadNeuroDB/tarchiveLoader @@ -436,7 +436,7 @@ if (!defined($subjectIDsref->{'visitLabel'})) { \$dbh ); } -my ($sessionID, $requiresStaging) = +my ($sessionID) = NeuroDB::MRI::getSessionID( $subjectIDsref, $tarchiveInfo{'DateAcquired'}, \$dbh, $subjectIDsref->{'subprojectID'} diff --git a/uploadNeuroDB/tarchive_validation.pl b/uploadNeuroDB/tarchive_validation.pl index 1638ed944..3abb1f3f0 100755 --- a/uploadNeuroDB/tarchive_validation.pl +++ b/uploadNeuroDB/tarchive_validation.pl @@ -371,7 +371,7 @@ =head2 Methods ################################################################ ############ Get the SessionID ################################# ################################################################ -my ($sessionID, $requiresStaging) = +my ($sessionID) = $utility->setMRISession($subjectIDsref, \%tarchiveInfo, $upload_id); ################################################################