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