Using StatefulTractogram in pyAFQ
Last week, I traveled to Austin, TX, to work with Tal Yarkoni on a new project, about which some other time. When I travel, I somehow have more time than usual to sit and program: late at night, early in the morning and on airplanes seem to be good times to focus somehow. This time, I had the opportunity to overhaul our approach to representation of tractography results in pyAFQ. One of the challenges of using tractography results is keeping track of the coordinate frame relative to which the three-dimensional curves are represented. In particular, as streamlines are brought in and out of register with other data, such as maps of diffusion MRI metrics. A recent development by Francois Rheault on DIPY is a class for stateful representation of tractograms. This was added in version 1.0 (pr) and continues to evolve in the 1.x series (here and here). This is a really good step forward in that it takes care of transformations efficiently and consistently, making sure that the resulting representation is consistent and correct. Overhauling our codebase to use this has been interesting and informative. In particular, it is not always clear when to shift to this type of object (rather than lists of arrays and ArraySequence objects) when working on functions that require multiple steps (e.g., in our waypoint ROI based segmentation). As noted in [one of the prs linked above)(here) it’s also common to want to initialize a new object based on the data in another object, and the risk of losing one or more bits of metadata can be a source of error. Nevertheless, this is clearly an improvement and the hope is that this data structure will serve as a good basis for other data structures that we would like to implement next. For example, bundles associated with particular anatomical structures and collections of these bundles.