Conditions | 1 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from datetime import datetime |
||
12 | def attach(self, form='json'): |
||
13 | """ |
||
14 | Attach the current provenance to the file by injecting it as a |
||
15 | json-encoded extension to the nifti header. |
||
16 | |||
17 | Args: |
||
18 | form (str): Data format in which to serialize provenance. Defaults |
||
19 | to 'json'. |
||
20 | """ |
||
21 | img = self.libs.nibabel.load(self.path) |
||
22 | provstr = self.getProvenance(form) |
||
23 | ext = self.libs.nibabel.nifti1.Nifti1Extension('comment', provstr) |
||
24 | hdr = img.get_header() |
||
25 | hdr.extensions.append(ext) |
||
26 | img.to_filename(self.path) |
||
27 | |||
33 |