Skip to content

Fix various little bugs preventing the insertion of a MINC file without DICOMs #1288

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

Closed
wants to merge 3 commits into from
Closed
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
119 changes: 72 additions & 47 deletions uploadNeuroDB/minc_insertion.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -403,7 +402,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 ".
Expand All @@ -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);
Expand Down Expand Up @@ -477,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;
}
}
Expand Down Expand Up @@ -555,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;
}
Expand All @@ -580,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);
Expand All @@ -606,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;
}

Expand Down Expand Up @@ -655,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;
}

################################################################
Expand All @@ -688,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;
}
################################################################
Expand All @@ -716,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";
}
Expand Down
Loading