Skip to content
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

Fix file count in mri_upload when deleting a minc file and then re-inserting: Redmine 12008 #180

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
24 changes: 24 additions & 0 deletions uploadNeuroDB/minc_deletion.pl
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,27 @@ sub selORdel {

# Delete file records last
selORdel("files","File");

# Update the number of minc inserted in mri_upload by subtracting one
if ($selORdel eq "DELETE ") {
$query = "SELECT number_of_mincInserted FROM mri_upload " .
"WHERE TarchiveID=?";

$sth = $dbh->prepare($query);
$sth->execute($tarchiveid);
my $nmi = $sth->fetchrow_array;

if ($sth->rows > 0) {
my $new_nmi = $nmi - 1;
$query = "UPDATE mri_upload SET number_of_mincInserted=? ".
"WHERE TarchiveID=?";

$sth = $dbh->prepare($query);
my $success = $sth->execute($new_nmi, $tarchiveid);

if ($success) {
print "\nNew count for number of mincs inserted changed to " . $new_nmi . "\n";
}
}
}

18 changes: 16 additions & 2 deletions uploadNeuroDB/tarchiveLoader
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ $utility->computeSNR($tarchiveInfo{TarchiveID},
$tarchiveInfo{'SourceLocation'},
$profile);
################################################################
############### Compute SNR on 3D modalities ###################
####### Add order of acquisition for similar modalities ########
####### within the same session based on series number #########
################################################################
$utility->orderModalitiesByAcq($tarchiveInfo{TarchiveID},
$tarchiveInfo{'SourceLocation'});
Expand All @@ -504,6 +505,19 @@ if ($valid_study) {
### And number_of_mincInserted #############################
############################################################
my $where = "WHERE TarchiveID=?";

$query =
"SELECT number_of_mincInserted FROM mri_upload ";
$query = $query . $where;
if ($debug) {
print $query . "\n";
}

my $sth = $dbh->prepare($query);
$sth->execute($tarchiveInfo{TarchiveID});
my $oldCount = $sth->fetchrow_array;
my $newCount = $minc_inserted + $oldCount;

$query = "UPDATE mri_upload SET number_of_mincInserted=?, ".
"number_of_mincCreated=? ";
$query = $query . $where;
Expand All @@ -513,7 +527,7 @@ if ($valid_study) {

my $mri_upload_update = $dbh->prepare($query);
$mri_upload_update->execute(
$minc_inserted,$mcount,$tarchiveInfo{TarchiveID}
$newCount,$mcount,$tarchiveInfo{TarchiveID}
);

############################################################
Expand Down