From bb28206988ae91fc9959844038d6dc6903223d38 Mon Sep 17 00:00:00 2001 From: MounaSafiHarab Date: Wed, 28 Feb 2018 16:15:23 -0500 Subject: [PATCH] [post 19.0.0 release] loris-mri-docs: forward changes from v19.0.0 and resolve conflicts (#280) * Initial import of files from http://code.google.com/p/dicom-archive/ * add two configurable options is_site and is_sge * Added new getIncomingDir config function * Added missing semi-colons. * Modifies the temporairy values of $data_dir, $get_dicom_info and $mail_user variables * Places back the forward slash in the email-address * Modifies the temporairy value for the tarchive_librairy location * Modified the tarchivelibdir temp value * Set the if_sge to false by default * Fixed the dcmodify --insert-tag option to --insert (option used in more recent dcmodify). * Updates the mri_upload table * Includes option to update the mri_upload table * Modification to the profileTemplate to be able to use DTIPrep pipeline * Added get_DTI_Site_CandID_Visit function in profile file * Cosmetic changes * Cosmetic changes * Fixed typos and indentation * Correct spelling mistakes * 1) added the functionality to insert the extension , 2) fixed indentation * Removed the filetype option * Changed the queries to use the prepared statements * Modified $d to $dir in profileTemplate * Remove .DS_Store file from DICOM source directory before creating new object. Other fails while reading content of dcm source directory * Modified getSubjectIDs so that it uses PatientName instead of PatientID lookupCenterID using patient name instead of PatientID * modified: profileTemplate * Moved reference to ~/.neurodb to .loris_mri directory * Some more files * Replaced .neurodb by .loris_mri in updateHeaders.pl * Removed the full path * DicomTar.pl should use proper $profile name instead of prod * Sometime DICOM Header may not have Invertion Time field (0018,9079). Set Inversion Time to 0 in tarchive_series to avoid error message: DBD::mysql::st execute failed: Data truncated for column 'InversionTime' * DICOM HEADER may not have Inversion time (0018,9079) set which cause tarchives_series sql table who expect a double to receive an empty string. * THIS IS A DUPLICATE from opionnalProfileFixInDicomTar pull request please ignore change in dicomTar.pl THIS IS A DUPLICATE from opionnalProfileFixInDicomTar pull request please ignore change in dicomTar.pl * removed useless numbers * Added $subjectID{'createVisitLabel'} option to profile template. * Changed $subjectID{'createVisitLabel'} type to boolean * added exit 0 at the end of the file * cosmetic change * Added a new option config $bin_dir * Fixed the option * Defined(@array) is deprecated. Removed error message on the console defined(@array) is deprecated at... (Maybe you should just omit the defined()?) * Removed all occurences of defined(@array). * replaced the sourcelocation column by DecompressedLocation * Added functionality to insert PET DICOMs in tarchive tables. * Fixed indentation in the pull request. * NIfTI support of the imaging pipeline (profileTemplate change). * Added -centerName option in call to dicomTar.pl. * Made ArchiveLocation relative in tarchive table. * Created a MySQL scripted patch to make ArchiveLocation in the tarchive table relative. * Added functionality to print query on one line. * Cleaned up and prepared statement for queries in main directory of dicom-archive-tools * Prepared mysql statement for DCMSUM.pm * Fixed bug inserted while integrating mysql prepare statements * Removed the Deprecated definition of array: !@Settings instead of !defined @Settings, to be in line with pull request #95 * One more consistency check on verbose and notification spool tables * One more explicit Done message * Fixes the insert in DCMSUM.pm so it does not set the creatinguser field in the tarchive table to NULL when the pipeline is run in auto-launch mode. * site or rather, study, no longer hard coded * removed extra ~ and the comments as per Cecile feedback * adding TarchiveSeriesID to the tarchive_files * Added the getSNRModalities function * added flair * typo * typo AGAIN * added comment based on SeriesUID and EchoTime * Removed getIncomingDir routine from profileTemplate; it is no longer used. Same as PR35 * Revert "adding TarchiveSeriesID to the tarchive_files" * isFileToBeRegisteredGivenProtocol in Profile now returns 1 if ne unknown * Incorporate comment of Dave * I cna not type wihtout making typos * re-adding TarchiveSeriesID to the tarchive_files * swap inserts * added comment * updated the comment with tarchive_files * Loris-MRI configurations moved to the front end from the $profile file: Redmine 8893 (#182) * Loris-MRI configurations moved to the front end from the $profile file: Redmine 8893 * went through all the files that get the settings from the prod file * added the install scripts * removed prefix from the Get_DTI_Site function * added data_dir as projects like IBIS could have it different from mincPath * Greg feedback on DB::DBI, removal of defined, and a masked variable declaration * added the script for existing projects to populate their default database values with those from their prod file * function return value * IBIS has all sorts of differences, the updates in this commit account for those * data_dir renamed to dataDirBasepath * Cecile feedback and applying her comments to all other files * fixed the message where the values is kept at its default, and removed debug print * Loris-MRI configurations moved to the front end from the $profile file: Redmine 8893 (#45) * Loris-MRI configurations moved to the front end from the $profile file: Redmine 8893 * went through all the files that get the settings from the prod file * removed prefix from the Get_DTI_Site function * consistency in DB versus NeuroDB * one dollar sign instead of 2; but have no clue why * Cecile required changes * [ImagingUpload.pm] Look inside file type and not file path for the word dicom (#178) * Look inside file type and not file path for the word dicom * check for the whole dicom type string * spaces * spaces * Fix file count in mri_upload when deleting a minc file and then re-inserting (#180) * fixed minc deletion (#185) * Remove all .DS_Store files anywhere in the tree, and __MACOSX directory (#46) * Remove all .DS_Store files anywhere in the tree * The command will not complain even if it does not find a file to delete. * Incorporate the additional changes from Mouna * Removed files starting with . and __MACOSX directory from the uploaded scans: Redmine 11670 (#186) * started * first attempt finished * cleanup * included mounas feedback * Updating README with proper dpkg (#190) * [Installation] Fixing more installation errors (#191) * Fixing more errors * This will be much clearer * changed new_nmi to nmi * missed one :p * [SQL] Fixing MySQL 5.7 group by during visit creation (#192) * Fixing MySQL 5.7 group by during visit creation * Missed comma * Removing newVisitNo in group by * Added option to also re-insert deleted minc files (Same as PR#179) (#193) * added option to also re-insert * Remove profile changes * removing IBIS specific fields * No need to show another example of sql query * adding documentation and making sql more generic * more updates * fix path to run from mri directory * Option to re-insert deleted minc files: Based off of PR 179 * remove the original file * better readme * Cecile comments * relative to example scripts directory * Modified the deletemincsqlwrapper.pl so that when no files are found with the query, it prints it out so that the user do not feel like nothing happened. * revert to t1 from adniT1 * remove the wrong file * minor thing * chmod, run tarchiveLoader without seriesUID as an argument, and small messages change * [Install] Readme Version update, installer CentOS improvements (#188) * committing Readme version and installer changes * adding Readme changes * setting VERSION file to 18.0.0 * additional Readme updates * formatting in Readme * re-integrating updates * removing period * New installs now also have their Imaging Pipeline ConfigSettings populated based on the user answers during the installation process: Redmine 13199 * minor echo message change * rebasing removed Christine changes so add them again * update the dicom archive repo link (#199) Update submodule link for dicom_archive. * Do not store PatientName header in notification_spool table:Redmine 13506 * update README * Check consistent upload_id and filename when running the pipeline: Redmine 13507 (#202) * Check consistent upload_id and filename when running the pipeline: Redmine 13507 * make copy and paste a bit more intelligent * Mapping empty date of birth and scan to undef when empty so that it can be inserted in MySQL 5.7 (#205) * Creected code that tests if two float numbers are equal (#206) * [Cleanup]: Remove duplicate DBI.pm; Redmine 13613 (#207) * Add TarchiveID to mri_protocol_violated_scans (#211) * Adding TarchiveID information in mri_protocol_violated_scans table * Cleaned up commented parts * Renamed $tarchiveInfo to $tarchiveInfoRef for consistencies * Get file list after removal of undesired directories like __MACOSX: Redmine 13508 (#203) * Get file list after removal of undesired directories like __MACOSX: Redmine 13508 * change xargs to deleting from the find command * Dave and Nick feedback * Nicolas feedback; escaping the directory name * Refactor smart matching code in DTI.pm (#215) * Better MINC toolkit sourcing command in README and updated VERSION file (#260) * Better MINC toolkit sourcing command and updated VERSION file * cecile feedback * Updating QC tables if the -deleteQCdata flag is not set. Will update FileID to NULL in files_qcstatus and feedback_mri_comments (#261) * README has also within it LORIS-MRI version number, so update (#268) * Installer: Populate the default LORIS config settings for the MRI paths (Redmine 13915) (#272) * Populate Loris-MRI code path for new installs since the user is asked to enter the MRI project name * Populate other MRI data path with a better option than the default LORIS %PROJECTNAME * post installation checks * Add the condition Dave brought up during the imaging meeting; i.e. only change it for those that did not do it in the front end already * Ceciles feedback * oopsie * resolve some unresolved conflicts and remove all added empty lines * Ceciles feedback to remove duplicate getconfigsetting * feedback after discussing with Nick --- DTIPrep/DTI/DTI.pm | 7 ++- batch_uploads_imageuploader | 2 +- dicom-archive/DICOM/DCMSUM.pm | 2 +- dicom-archive/dicomTar.pl | 2 +- imaging_install.sh | 10 ++-- uploadNeuroDB/NeuroDB/ImagingUpload.pm | 15 +++--- uploadNeuroDB/NeuroDB/MRI.pm | 49 ++++++++++++++++--- uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm | 9 ++-- uploadNeuroDB/mass_pic.pl | 2 +- uploadNeuroDB/minc_deletion.pl | 38 +++++++++++--- uploadNeuroDB/minc_insertion.pl | 2 +- 11 files changed, 103 insertions(+), 35 deletions(-) diff --git a/DTIPrep/DTI/DTI.pm b/DTIPrep/DTI/DTI.pm index 7e0041a2d..5e185b33f 100755 --- a/DTIPrep/DTI/DTI.pm +++ b/DTIPrep/DTI/DTI.pm @@ -143,12 +143,17 @@ sub getRawDTIFiles{ ## Grab the mincs I want, a.k.a. with minc file with $DTI_volumes my @DTI_frames = split(',',$DTI_volumes); + + # Filter the frames list: keep only the strings that are integers + # (this should not remove anything since the $DTI_volumes string is + # assumed to be a comma separated list of integers) + @DTI_frames = grep($_ =~ /^\s*\d+\s*$/, @DTI_frames); my @DTIs_list = (); foreach my $mnc (@$mincs_list) { if (`mincinfo -dimnames $mnc` =~ m/time/) { my $time = `mincinfo -dimlength time $mnc`; chomp($time); - if ($time ~~ \@DTI_frames) { + if (grep($time == $_, @DTI_frames)) { push (@DTIs_list, $mnc); } } diff --git a/batch_uploads_imageuploader b/batch_uploads_imageuploader index 2a530a856..cbb690c61 100755 --- a/batch_uploads_imageuploader +++ b/batch_uploads_imageuploader @@ -334,4 +334,4 @@ License: GPLv3 LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut diff --git a/dicom-archive/DICOM/DCMSUM.pm b/dicom-archive/DICOM/DCMSUM.pm index 2bae7ef51..d4a921aba 100644 --- a/dicom-archive/DICOM/DCMSUM.pm +++ b/dicom-archive/DICOM/DCMSUM.pm @@ -1185,4 +1185,4 @@ License: GPLv3 J-Sebastian Muehlboeck, LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut diff --git a/dicom-archive/dicomTar.pl b/dicom-archive/dicomTar.pl index 478da33b2..21c7ce2c3 100755 --- a/dicom-archive/dicomTar.pl +++ b/dicom-archive/dicomTar.pl @@ -396,4 +396,4 @@ =head1 AUTHORS LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut diff --git a/imaging_install.sh b/imaging_install.sh index 1dbc810ea..3adf22a10 100755 --- a/imaging_install.sh +++ b/imaging_install.sh @@ -187,10 +187,14 @@ fi ###################################################################### ###### Update the Database table, Config, with the user values ####### ###################################################################### -echo "Populating database configuration entries for the Imaging Pipeline:" -mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dataDirBasepath')" +echo "Populating database configuration entries for the Imaging Pipeline and LORIS-MRI code and images Path:" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dataDirBasepath')" mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='$PROJ' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='prefix')" mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='$email' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='mail_user')" mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/bin/mri/dicom-archive/get_dicom_info.pl' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='get_dicom_info')" -mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/tarchive' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='tarchiveLibraryDir')" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/tarchive/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='tarchiveLibraryDir')" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='imagePath') AND Value = '/data/%PROJECTNAME%/data/'" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='data') AND Value = '/data/%PROJECTNAME%/data/'" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='mincPath') AND Value = '/data/%PROJECTNAME%/data/'" +mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/bin/mri/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='MRICodePath') AND Value = '/data/%PROJECTNAME%/bin/mri/'" echo diff --git a/uploadNeuroDB/NeuroDB/ImagingUpload.pm b/uploadNeuroDB/NeuroDB/ImagingUpload.pm index dc5549c39..39bc7ffa9 100755 --- a/uploadNeuroDB/NeuroDB/ImagingUpload.pm +++ b/uploadNeuroDB/NeuroDB/ImagingUpload.pm @@ -152,10 +152,16 @@ sub IsCandidateInfoValid { my $files_with_unmatched_patient_name = 0; my $is_candinfovalid = 0; my @row = (); + ############################################################ + ####Remove __MACOSX directory from the upload if found###### ####Get a list of files from the folder##################### #############Loop through the files######################### ############################################################ + my $cmd = "find -path " . quotemeta($this->{'uploaded_temp_folder'}) . " -name '__MACOSX' -delete "; + print "\n $cmd \n"; + system($cmd); + my @file_list; find( sub { @@ -234,13 +240,6 @@ sub IsCandidateInfoValid { return 0; } - - ############################################################ - ####Remove __MACOSX directory from the upload ############## - ############################################################ - my $cmd = "cd " . $this->{'uploaded_temp_folder'} . "; find -name '__MACOSX' | xargs rm -rf"; - system($cmd); - foreach (@file_list) { ######################################################## #1) Exlcude files starting with . (and ._ as a result)## @@ -250,7 +249,7 @@ sub IsCandidateInfoValid { ######################################################## if ( (basename($_) =~ /^\./)) { $cmd = "rm " . ($_); - print ($cmd); + print "\n $cmd \n"; system($cmd); } else { diff --git a/uploadNeuroDB/NeuroDB/MRI.pm b/uploadNeuroDB/NeuroDB/MRI.pm index f84cae4b7..4ee3350eb 100755 --- a/uploadNeuroDB/NeuroDB/MRI.pm +++ b/uploadNeuroDB/NeuroDB/MRI.pm @@ -460,11 +460,13 @@ RETURNS: textual name of scan type from the C table sub identify_scan_db { - my ($psc, $subjectref, $fileref, $dbhr,$minc_location) = @_; + my ($psc, $subjectref, $tarchiveInfoRef, $fileref, $dbhr,$minc_location + ) = @_; my $candid = ${subjectref}->{'CandID'}; my $pscid = ${subjectref}->{'PSCID'}; my $visit = ${subjectref}->{'visitLabel'}; + my $tarchiveID = $tarchiveInfoRef->{'TarchiveID'}; my $objective = ${subjectref}->{'subprojectID'}; # get parameters from minc header @@ -587,7 +589,13 @@ sub identify_scan_db { } # if we got here, we're really clueless... - insert_violated_scans($dbhr,$series_description,$minc_location,$patient_name,$candid, $pscid,$visit,$tr,$te,$ti,$slice_thickness,$xstep,$ystep,$zstep,$xspace,$yspace,$zspace,$time,$seriesUID); + insert_violated_scans( + $dbhr, $series_description, $minc_location, $patient_name, + $candid, $pscid, $tr, $te, + $ti, $slice_thickness, $xstep, $ystep, + $zstep, $xspace, $yspace, $zspace, + $time, $seriesUID, $tarchiveID + ); return 'unknown'; } @@ -625,12 +633,36 @@ INPUTS: sub insert_violated_scans { - my ($dbhr,$series_description,$minc_location,$patient_name,$candid, $pscid,$visit,$tr,$te,$ti,$slice_thickness,$xstep,$ystep,$zstep,$xspace,$yspace,$zspace,$time,$seriesUID) = @_; - my $query; - my $sth; - - $sth = $${dbhr}->prepare("INSERT INTO mri_protocol_violated_scans (CandID,PSCID,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) VALUES (?,?,now(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); - my $success = $sth->execute($candid,$pscid,$series_description,$minc_location,$patient_name,$tr,$te,$ti,$slice_thickness,$xspace,$yspace,$zspace,$xstep,$ystep,$zstep,$time,$seriesUID); + my ($dbhr, $series_description, $minc_location, $patient_name, + $candid, $pscid, $tr, $te, + $ti, $slice_thickness, $xstep, $ystep, + $zstep, $xspace, $yspace, $zspace, + $time, $seriesUID, $tarchiveID) = @_; + + (my $query = <prepare($query); + my $success = $sth->execute( + $candid, $pscid, $tarchiveID, $series_description, + $minc_location, $patient_name, $tr, $te, + $ti, $slice_thickness, $xspace, $yspace, + $zspace, $xstep, $ystep, $zstep, + $time, $seriesUID + ); } @@ -762,6 +794,7 @@ INPUTS: float 1, float 2 and the number of first decimals RETURNS: 1 if the numbers are relatively equal, 0 otherwise =cut + sub floats_are_equal { my($f1, $f2, $nb_decimals) = @_; diff --git a/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm b/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm index 8076c9797..150c41672 100755 --- a/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm +++ b/uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm @@ -608,8 +608,8 @@ RETURNS: acquisition protocol, acquisition protocol ID, array of extra checks sub getAcquisitionProtocol { my $this = shift; - my ($file,$subjectIDsref,$tarchiveInfo,$center_name,$minc,$acquisitionProtocol,$bypass_extra_file_checks) = @_; - my $tarchive_srcloc = $tarchiveInfo->{'SourceLocation'}; + my ($file,$subjectIDsref,$tarchiveInfoRef,$center_name,$minc,$acquisitionProtocol,$bypass_extra_file_checks) = @_; + my $tarchive_srcloc = $tarchiveInfoRef->{'SourceLocation'}; my $upload_id = getUploadIDUsingTarchiveSrcLoc($tarchive_srcloc); my $message = ''; @@ -625,6 +625,7 @@ sub getAcquisitionProtocol { $acquisitionProtocol = &NeuroDB::MRI::identify_scan_db( $center_name, $subjectIDsref, + $tarchiveInfoRef, $file, $this->{dbhr}, $minc @@ -649,7 +650,7 @@ sub getAcquisitionProtocol { $file, $subjectIDsref->{'CandID'}, $subjectIDsref->{'visitLabel'}, - $tarchiveInfo->{'PatientName'} + $tarchiveInfoRef->{'PatientName'} ); $message = "\nextra_file_checks from table mri_protocol_check " . "logged in table mri_violations_log: $checks[0]\n"; @@ -1824,4 +1825,4 @@ License: GPLv3 LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut diff --git a/uploadNeuroDB/mass_pic.pl b/uploadNeuroDB/mass_pic.pl index 23309fa2b..4030668e8 100755 --- a/uploadNeuroDB/mass_pic.pl +++ b/uploadNeuroDB/mass_pic.pl @@ -185,4 +185,4 @@ =head1 AUTHORS LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut diff --git a/uploadNeuroDB/minc_deletion.pl b/uploadNeuroDB/minc_deletion.pl index 08b376367..a02c17fea 100755 --- a/uploadNeuroDB/minc_deletion.pl +++ b/uploadNeuroDB/minc_deletion.pl @@ -68,8 +68,9 @@ =head1 DESCRIPTION =~ /: (\d+)\.(\d+)/; my $profile = ''; # this should never be set unless you are in a # stable production environment -my $seriesuid = ''; -my $fileid = ''; +my $seriesuid = ''; # seriesUID value from script inputs +my $fileid = ''; # fileID value from script inputs +my @files_FileID; # fileID value from query of the files table my $sth; my $rvl; my $query = ''; @@ -221,7 +222,7 @@ sub selORdel { # Delete from FS: # get the file names -$query = "select f.File, f.TarchiveSource, f.SessionID, pf.`VALUE` from files as f ". +$query = "select f.File, f.TarchiveSource, f.SessionID, pf.`VALUE`, f.FileID from files as f ". "left join parameter_file as pf using (FileID) where ". "pf.ParameterTypeID = (select pt.ParameterTypeID from parameter_type as pt where pt.Name = 'check_pic_filename') and ". "pf.FileID IN "; @@ -253,6 +254,9 @@ sub selORdel { while (my $f = $sth->fetchrow_hashref()) { $tarchiveid = $f->{'TarchiveSource'}; $sessionid = $f->{'SessionID'}; + # grep the list of fileIDs from the files table and organize them so they + # can be given in a "WHERE FileID IN ()" syntax + push(@files_FileID, $f->{'FileID'}); @pic_path = split /_check/, $f->{'VALUE'}; $jiv_header = $pic_path[0] . ".header"; $jiv_raw_byte = $pic_path[0] . ".raw_byte.gz"; @@ -288,11 +292,33 @@ sub selORdel { print "\nDelete from DB"; # Delete from DB -selORdel("parameter_file","Value"); -if ($delqcdata) { + +# Take care of the QC data +if (($delqcdata) || ($selORdel eq "SELECT * ")) { + ## if the "-delqcdata" option is set or the script is run in "select" mode + # executes queries in function selORdel (which will either "SELECT *" or + # "DELETE" from table given as argument to the function selORdel selORdel("files_qcstatus","QCStatus"); selORdel("feedback_mri_comments","Comment"); +} else { + ## if don't want to delete the QC data, will have to set their FileID to + # null so that it can be remapped to the new FileID based on their + # SeriesUID and echo time, and the FileID can be removed from the files + # table + foreach my $table ("files_qcstatus", "feedback_mri_comments") { + (my $updateQCquery = <prepare($updateQCquery); + $rvl = $sth->execute($_) for @files_FileID; + } } + +# Delete from parameter_file +selORdel("parameter_file","Value"); + # selORdel("mri_protocol_violated_scans","ID"); # if there is data here, the mnc will be in the trashbin # selORdel("MRICandidateErrors","Reason"); # not applicable to /assembly # selORdel("mri_violations_log","LogID"); # " @@ -309,7 +335,7 @@ sub selORdel { $field = "SeriesUID"; } else { $val = $fileid; - $field = "FileID" + $field = "FileID"; } # Check #1 in files, if other files from same session $query = "select * from files as g " . diff --git a/uploadNeuroDB/minc_insertion.pl b/uploadNeuroDB/minc_insertion.pl index 9385476d6..928c53794 100755 --- a/uploadNeuroDB/minc_insertion.pl +++ b/uploadNeuroDB/minc_insertion.pl @@ -615,4 +615,4 @@ =head1 AUTHORS LORIS community and McGill Centre for Integrative Neuroscience -=cut \ No newline at end of file +=cut