[Mrtrix-discussion] PATCH: fix writing to gzipped nifti when already exists
Donald Tournier
jdtournier at gmail.com
Tue May 6 03:47:14 PDT 2014
Hi Chris,
Thanks for the patch. Just a minor point though: the default behaviour in
MRtrix is to prevent any overwrite of existing image files (to prevent
accidental loss of data). While there are undeniably pro & cons to this
policy, for the sake of consistency it would be better if this just threw
an exception if the file exists. I'll include such a patch upstream based
on yours when I have a minute...
Cheers!
Donald.
On 2 May 2014 06:44, Chris Adamson <chris.adamson at mcri.edu.au> wrote:
> I found a serious bug when mrview overwrites an ROI image that is in nii
> gz format it crashes. This is a patch:
>
>
>
> diff -ru b/lib/image/mapper.cpp a/lib/image/mapper.cpp
>
> --- b/lib/image/mapper.cpp 2014-02-25 20:49:26.000000000 +1100
>
> +++ a/lib/image/mapper.cpp 2014-05-02 15:37:46.547683468 +1000
>
> @@ -210,6 +210,13 @@
>
> info ("writing compressed data to \"" + gzfile + "\"...");
>
> + // check if file exists,
>
> + if(g_file_test (gzfile.c_str(), G_FILE_TEST_EXISTS)) {
>
> + if(g_unlink(gzfile.c_str()) == -1) {
>
> + fclose (infile);
>
> + throw Exception ("error deleting file \"" + gzfile + "\": " +
> Glib::strerror(errno));
>
> + }
>
> + }
>
> int fid = g_open (gzfile.c_str(), O_CREAT | O_RDWR | O_EXCL, 0755);
>
> if (fid < 0) {
>
> fclose (infile);
>
>
>
> *Dr *
> *Chris Adamson *Research Officer, Developmental Imaging,
> *Murdoch Childrens Research Institute *Murdoch Childrens Research
> Institute
> Royal Children’s Hospital
> Flemington Road, Parkville, Victoria 3052, Australia
> www.mcri.edu.au
>
> E chris.adamson at mcri.edu.au
> T 03 9936 6780
>
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
> _______________________________________________
> Mrtrix-discussion mailing list
> Mrtrix-discussion at www.nitrc.org
> http://www.nitrc.org/mailman/listinfo/mrtrix-discussion
>
>
--
*Dr J-Donald Tournier (PhD)*
*Senior Lecturer, **Biomedical Engineering*
*Division of Imaging Sciences & Biomedical EngineeringKing's College London*
*A: Department of Perinatal Imaging & Health, 1st Floor South Wing, St
Thomas' Hospital, London. SE1 7EH*
*T: +44 (0)20 7188 7118 ext 53613*
*W: http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering
<http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.nitrc.org/pipermail/mrtrix-discussion/attachments/20140506/2cac1b61/attachment.html>
More information about the Mrtrix-discussion
mailing list