we are currently implementing a diffusion pipeline using Brainvisa which mixes several softwares (FSL and Dipy essentially) and are sometimes writing some outputs using FSL other using nibabel (dipy use it to save fiber bundles as trk files) and we are getting some surprises. Sometimes volumes have the same orientations sometimes not.. We started to dig a little bit, looking in the forum, both brainvisa and nibabel documentations, and nifti standards.. My loooong post (sorry for that) has two purpose. Trying to understand better how brainvisa and referentials system works and also find out a proper solution in order no to set up tansformation matrix manually.

- Data are stored in certain layout and when loaded to anatomist or aims, data is automatically put in Aims referential which is LPI the flipping is encoded in storage-to memory transformation. This is transparent for us users. If the storage is done properly (according to Nifti standards) can storage to memory correspond to RAS to LPI voxel spaces transformation ?
- Affine in the transformation field of the aims header does not correspond to the actual affine transformation encoded in the nifti header but to a recalculated transformation between Aims referential and let say Scanner Based referential. In particular scaling is not taken into account.
What happens if a Volume is created from scratch using the loaded header of a previously loaded Volume. What field will actually be saved in the physical nifti header ? In particular which affine ?
-Meshes do not have proper header and are assumed to be created in the mm LPI space with 0 being the center of the first voxel by default but different referential can be precise in the minf file associated.
We guess that a convenient way to solve most of our orientation problem is to keep information using the minf file and staying in the brainvisa way.
Last problem we have is that fiber bundles are written with nibabel into the trk format. The bundles are then i the trackvis system coordinates. Referential seems to be well recognized into trackvis but not into anatomist. If we set this info into the minf file will brainvisa recognize it ? If not is there a way to retrieve classical referential (other than MNI and Talairach) using brainvisa or aims ?
Thank you very much ^^