<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear Cécile, Ling ma, and Nicolas,
<div class=""><br class="">
</div>
<div class="">I modified my scripts to execute the solutions you provided. @Cecile, the option -ignored worked perfect. @Nicolas, there were multiple entries in â€œmri_upload” linked to the same TarchiveID indeed.</div>
<div class=""><br class="">
</div>
<div class="">Now all the UploadIDs linked to the study I am removing images from are now deleted. However, in the front-end I can still see 8 imaging visits! I will send an email explaining the issue.</div>
<div class=""><br class="">
</div>
<div class="">Thank you again.</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Alfredo.<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 7, 2020, at 8:06 AM, Nicolas Brossard <<a href="mailto:nicolasbrossard.mni@gmail.com" class="">nicolasbrossard.mni@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="padding: 3px 10px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; color: rgb(255, 255, 255); font-weight: bold; display: inline-block; background-color: rgb(255, 0, 0);" class="">        External
 Email - Use Caution        </span></p>
<div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br class="webkit-block-placeholder">
</div>
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
Hi all,<br class="">
<div class=""><br class="">
</div>
<div class="">Regarding the foreign key constraint fail error, my guess is that you have two records in mri_uploads that are tied to the same archive and you are trying to delete one of them. What I am saying is that you have two uploads, say U1 and U2, which
 have the same tarchive ID, say A1. If you try to delete U1, the script will try to delete everything associated to it, including archive A1, which will fail because of the foreign key constraint still tying U2 to A1. This is unfortunately a bug of the delete
 script. </div>
<div class=""><br class="">
</div>
<div class="">You should be able to delete *all* the uploads that have the same tarchive ID though, but you'd have to do it in the same script invocation. So back to our example, you could delete U1 and U2 but you'd have to delete them at the same time by supplying
 both upload IDs in a comma-separated list via the -uploadID switch (see the perldoc for the delete script).</div>
<div class=""><br class="">
</div>
<div class="">I hope this makes sense. Let me know if I you need more information.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Nicolas</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class="gmail_quote" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div dir="ltr" class="gmail_attr">On Mon, Apr 6, 2020 at 6:02 PM Cecile Madjar <<a href="mailto:cecile.madjar@mcin.ca" class="">cecile.madjar@mcin.ca</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" class="">
<div dir="ltr" class="">Hi Alfredo,
<div class=""><br class="">
</div>
<div class="">See answers below in blue.<br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Error type 1:<br class="">
===<br class="">
Error! File /ABC/data/pic/979907/IPMSA_979907_m00_NA_001_182_check.jpg exists in the database but was not found on the file system.<br class="">
Aborting.<br class="">
===<br class="">
<br class="">
Error type 2:<br class="">
===<br class="">
Error! File /ABC/data/assembly/677803/m12/mri/native/IPMSA_677803_m12_NA_002.nii exists in the database but was not found on the file system.<br class="">
Aborting.<br class="">
===<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class=""><font color="#0000ff" class="">The first two errors are the same. The delete script always checks first if the file is on the filesystem. My guess is that when you ran the pipeline, the path to the NIfTI file was inserted into the database even
 when the NIfTI file was not created due to some mnc2nii conversion errors (known bug that was fixed in release 22.0). You can use the option -ignore to ignore the check between database and file system.</font></div>
<div class=""><font color="#0000ff" class=""> </font></div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<br class="">
Error type 3:<br class="">
===<br class="">
/ABC/data/pic/819059/IPMSA_819059_m12_NA_006_3098_check.jpg<br class="">
/ABC/data/pic/819059/IPMSA_819059_m12_NA_007_3099_check.jpg<br class="">
/ABC/data/pic/819059/IPMSA_819059_m12_NA_008_3100_check.jpg<br class="">
/ABCdata/pic/819059/IPMSA_819059_m12_NA_009_3101_check.jpg<br class="">
/ABC/data/pic/819059/IPMSA_819059_m12_t1_001_3091_check.jpg<br class="">
/ABC/data/pic/819059/IPMSA_819059_m12_t1_002_3092_check.jpg<br class="">
/ABC/data/tarchive/2009/DCM_2009-12-10_ImagingUpload-7-57-r0hk9h.tar<br class="">
<br class="">
DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`IPMSA_LORIS`.`mri_upload`, CONSTRAINT `FK_mriupload_TarchiveID` FOREIGN KEY (`TarchiveID`) REFERENCES `tarchive` (`TarchiveID`)) at /data_/ipmsa/loris_data/IPMSA/bin/mri/tools//<a href="http://delete_imaging_upload.pl/" rel="noreferrer" target="_blank" class="">delete_imaging_upload.pl</a><span class="Apple-converted-space"> </span>line
 1612.<br class="">
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle database=IPMSA_LORIS;host=132.216.133.50;port=3306; at /data_/ipmsa/loris_data/IPMSA/bin/mri/tools//<a href="http://delete_imaging_upload.pl/" rel="noreferrer" target="_blank" class="">delete_imaging_upload.pl</a><span class="Apple-converted-space"> </span>line
 1612.<br class="">
===<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class=""><font color="#0000ff" class="">Not sure what is going on here. Could you point me to the file so I can check where the issue comes from? Or the release version you are using. Are there any processed output data for that upload ID?</font></div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<br class="">
Error type 4:<br class="">
===<br class="">
Cannot delete upload 1543: the MRI pipeline is currently processing it.<br class="">
===<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class=""><font color="#0000ff" class="">If you are sure you are not running the pipeline, you will need to update the mri_upload table to reflect this. For some obscure reason, the insertion status fields of the mri_upload table were not updated for that
 UploadID. Maybe the pipeline got interrupted?</font></div>
<div class=""><font color="#0000ff" class="">UPDATE mri_upload SET Inserting=0, InsertionComplete=1 WHERE UploadID=1543;</font></div>
<div class=""><font color="#0000ff" class="">Then, rerun the delete script on that UploadID.</font></div>
<div class=""><font color="#0000ff" class=""><br class="">
</font></div>
<div class=""><font color="#0000ff" class="">Hope this helps. Best,</font></div>
<div class=""><font color="#0000ff" class=""><br class="">
</font></div>
<div class=""><font color="#0000ff" class="">Cécile</font></div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Looking forward to hearing from you.<br class="">
<br class="">
Regards,<br class="">
Alfredo.<br class="">
<br class="">
_______________________________________________<br class="">
Loris-dev mailing list<br class="">
<a href="mailto:Loris-dev@bic.mni.mcgill.ca" target="_blank" class="">Loris-dev@bic.mni.mcgill.ca</a><br class="">
<a href="https://mailman.bic.mni.mcgill.ca/mailman/listinfo/loris-dev" rel="noreferrer" target="_blank" class="">https://mailman.bic.mni.mcgill.ca/mailman/listinfo/loris-dev</a><br class="">
</blockquote>
</div>
</div>
_______________________________________________<br class="">
Loris-dev mailing list<br class="">
<a href="mailto:Loris-dev@bic.mni.mcgill.ca" target="_blank" class="">Loris-dev@bic.mni.mcgill.ca</a><br class="">
<a href="https://mailman.bic.mni.mcgill.ca/mailman/listinfo/loris-dev" rel="noreferrer" target="_blank" class="">https://mailman.bic.mni.mcgill.ca/mailman/listinfo/loris-dev</a></blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
<p></p>

<p>The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
http://www.partners.org/complianceline . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.</p></body>
</html>