From f0fa3adc1e10149f2c591ea0564a62d16ee7f312 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Thu, 22 May 2025 14:15:48 -0400 Subject: [PATCH 1/3] fix bug --- uploadNeuroDB/minc_insertion.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uploadNeuroDB/minc_insertion.pl b/uploadNeuroDB/minc_insertion.pl index 7462361a5..b0f4bdd62 100755 --- a/uploadNeuroDB/minc_insertion.pl +++ b/uploadNeuroDB/minc_insertion.pl @@ -403,7 +403,7 @@ =head2 Methods $is_valid = 1; # if it is HRRT datasets, mark study as valid } -if (($is_valid == 0) && ($force==0)) { +if (!$is_valid && !$force) { $message = "\n ERROR: The validation has failed. ". "Either run the validation again and fix ". "the problem. Or use -force to force the ". From 9c51c90344b66b7b196d4a566e0e2a7811925894 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Thu, 22 May 2025 14:40:01 -0400 Subject: [PATCH 2/3] more bug fix --- uploadNeuroDB/minc_insertion.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/uploadNeuroDB/minc_insertion.pl b/uploadNeuroDB/minc_insertion.pl index b0f4bdd62..cb888accc 100755 --- a/uploadNeuroDB/minc_insertion.pl +++ b/uploadNeuroDB/minc_insertion.pl @@ -355,9 +355,6 @@ =head2 Methods $is_valid = $array[0]; $ArchiveLocation = $array[1]; - # create the studyInfo object - %studyInfo = $utility->createTarchiveArray($ArchiveLocation); - } elsif ($tarchive) { my $mriUploadOB = NeuroDB::objectBroker::MriUploadOB->new(db => $db); my $mriUploadsRef = $mriUploadOB->getWithTarchive(GET_COLUMNS, $tarchive); @@ -383,6 +380,8 @@ =head2 Methods my %row = %{ $mriUploadsRef->[0] }; $is_valid = $row{'isTarchiveValidated'}; $upload_id = $row{'UploadID'}; + $ArchiveLocation = $tarchive; + $ArchiveLocation =~ s/$tarchiveLibraryDir//; } } elsif ($hrrt) { @@ -419,8 +418,11 @@ =head2 Methods ## Construct the tarchiveinfo Array and the MINC file object -# Create the study info array -%studyInfo = $utility->createTarchiveArray($ArchiveLocation, $hrrt); +# Create the study info array if ArchiveLocation is defined, otherwise, will populate +# with MINC file header later on +if (defined $ArchiveLocation) { + %studyInfo = $utility->createTarchiveArray($ArchiveLocation, $hrrt); +} # Create the MINC file object and maps DICOM fields my $file = $utility->loadAndCreateObjectFile($minc, $upload_id); From 9ef65aab7399f4018821ee61aa2e82d39f570c16 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Thu, 22 May 2025 15:00:09 -0400 Subject: [PATCH 3/3] more bug fix --- uploadNeuroDB/minc_insertion.pl | 105 +++++++++++++++++++------------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/uploadNeuroDB/minc_insertion.pl b/uploadNeuroDB/minc_insertion.pl index cb888accc..fdc1a95d8 100755 --- a/uploadNeuroDB/minc_insertion.pl +++ b/uploadNeuroDB/minc_insertion.pl @@ -479,11 +479,13 @@ =head2 Methods $utility->writeErrorLog( $message, $NeuroDB::ExitCodes::INVALID_ARG, $logfile ); - $notifier->spool( - 'tarchive validation', $message, 0, - 'minc_insertion.pl', $upload_id, 'Y', - $notify_notsummary - ); + if (defined $upload_id) { + $notifier->spool( + 'tarchive validation', $message, 0, + 'minc_insertion.pl', $upload_id, 'Y', + $notify_notsummary + ); + } exit $NeuroDB::ExitCodes::INVALID_ARG; } } @@ -557,9 +559,14 @@ =head2 Methods } $mriCandidateErrorsOB->insert(\%newMriCandidateErrors) unless defined $already_inserted; - $notifier->spool('tarchive validation', $message, 0, - 'minc_insertion.pl', $upload_id, 'Y', - $notify_notsummary); + if (defined $upload_id) { + $notifier->spool( + 'tarchive validation', $message, 0, + 'minc_insertion.pl', $upload_id, 'Y', + $notify_notsummary + ); + } + exit $NeuroDB::ExitCodes::CANDIDATE_MISMATCH; } @@ -582,11 +589,14 @@ =head2 Methods if (!$sessionRef) { print STDERR $errMsg if $verbose; print LOG $errMsg; - $notifier->spool( - 'tarchive validation', "$errMsg. Minc insertion failed.", 0, - 'minc_insertion.pl', $upload_id, 'Y', - $notify_notsummary - ); + if (defined $upload_id) { + $notifier->spool( + 'tarchive validation', "$errMsg. Minc insertion failed.", 0, + 'minc_insertion.pl', $upload_id, 'Y', + $notify_notsummary + ); + } + exit ($subjectIDsref->{'createVisitLabel'} == 1 ? $NeuroDB::ExitCodes::CREATE_SESSION_FAILURE : $NeuroDB::ExitCodes::GET_SESSION_ID_FAILURE); @@ -608,11 +618,13 @@ =head2 Methods if ($not_unique_message) { print STDERR $not_unique_message if $verbose; print LOG $not_unique_message; - $notifier->spool( - 'tarchive validation', $not_unique_message, 0, - 'minc_insertion.pl', $upload_id, 'Y', - $notify_notsummary - ); + if (defined $upload_id) { + $notifier->spool( + 'tarchive validation', $not_unique_message, 0, + 'minc_insertion.pl', $upload_id, 'Y', + $notify_notsummary + ); + } exit $NeuroDB::ExitCodes::FILE_NOT_UNIQUE; } @@ -657,15 +669,19 @@ =head2 Methods ); if($acquisitionProtocol =~ /unknown/ && !defined $acquisitionProtocolID) { - $message = "\n --> The MINC file cannot be registered since the ". - "AcquisitionProtocol is unknown and AcquisitionProtocol ID is undefined \n"; - - print LOG $message; - print $message; - $notifier->spool('minc insertion', $message, 0, - 'minc_insertion.pl', $upload_id, 'Y', - $notify_notsummary); - exit $NeuroDB::ExitCodes::UNKNOWN_PROTOCOL; + $message = "\n --> The MINC file cannot be registered since the ". + "AcquisitionProtocol is unknown and AcquisitionProtocol ID is undefined \n"; + + print LOG $message; + print $message; + if (defined $upload_id) { + $notifier->spool( + 'minc insertion', $message, 0, + 'minc_insertion.pl', $upload_id, 'Y', + $notify_notsummary + ); + } + exit $NeuroDB::ExitCodes::UNKNOWN_PROTOCOL; } ################################################################ @@ -690,15 +706,19 @@ =head2 Methods if ((!defined$success) && (defined(&Settings::isFileToBeRegisteredGivenProtocol)) ) { - $message = "\n --> The minc file cannot be registered ". - "since $acquisitionProtocol ". - "does not exist in $profile ". - "or it did not pass the extra_file_checks\n"; - print LOG $message; - print $message; - $notifier->spool('minc insertion', $message, 0, - 'minc_insertion', $upload_id, 'Y', - $notify_notsummary); + $message = "\n --> The minc file cannot be registered ". + "since $acquisitionProtocol ". + "does not exist in $profile ". + "or it did not pass the extra_file_checks\n"; + print LOG $message; + print $message; + if (defined $upload_id) { + $notifier->spool( + 'minc insertion', $message, 0, + 'minc_insertion', $upload_id, 'Y', + $notify_notsummary + ); + } exit $NeuroDB::ExitCodes::PROJECT_CUSTOMIZATION_FAILURE; } ################################################################ @@ -718,11 +738,14 @@ =head2 Methods my $spool_type = $hrrt ? 'hrrt pet new series' : 'mri new series'; -$notifier->spool( - $spool_type, $message, 0, - 'minc_insertion.pl', $upload_id, 'N', - $notify_detailed -); +if (defined $upload_id) { + $notifier->spool( + $spool_type, $message, 0, + 'minc_insertion.pl', $upload_id, 'N', + $notify_detailed + ); +} + if ($verbose) { print "\nFinished file: ".$file->getFileDatum('File')." \n"; }