[MINC-users] Adding to minc history

jon pipitone jon.pipitone at utoronto.ca
Sun Feb 17 13:35:23 EST 2013


Thanks guys, this is perfect. minc_modify_header to the rescue.

Jon.




On Thu, Feb 14, 2013 at 3:00 PM, Andrew Janke <a.janke at gmail.com> wrote:

> Hi Jon,
>
> > I'd like to be able to add entries to the history attribute of a minc
> file
> > so that I can record provenance when I process files with the various
> > scripts I've written up. I know many of the minc tools do this
> > automatically, but I also want my shell and python scripts to do this as
> > well.
>
> Good plan!  I endeavour to do this with all scripts I write. Note that
> you sometime also need to add history to xfm files and tag files.
>
> > Is there an already baked tool for this?  I imagine it would be easy to
> > roll something on my own by modifying the HDF headers, but I'd rather use
> > something that has had some field testing.
>
> There is no pre-baked tool if only because what you want to add
> changes from script to script. Or at least this is what I have found.
> In perl, the bit(s) of code I use are like this:
>
>
> $me = &basename($0);
>
> # get history string
> chomp($history = `date`);
> $history .= '>>>> ' . join(' ', $me, @ARGV) . "\n";
>
> # add the history string to the output file
> &do_cmd('minc_modify_header',
>    '-sappend', ":history='$history'",
>    $outfile);
>
>
> sub do_cmd {
>    print STDOUT "@_\n" if $opt{'verbose'};
>    if(!$opt{'fake'}){
>       system(@_) == 0 or die;
>       }
>    }
>
> ---
>
> Note that in order to get the history string you must put the first
> bits of code before you do any argument processing.
>
> A code example can be found here:
>
>    http://packages.bic.mni.mcgill.ca/scripts/volflip
>
>
> a
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


More information about the MINC-users mailing list