I would like to be able to get a resampled image slice as a numpy array by supplying a slice center (in RAS coord), slice dimensions and resolution (e.g. 50x50 pixels which are 1 mm x 1 mm), a slice normal vector, and a slice view-up vector. From looking at the Curved Planar Reformat module code, I was able to put together a function which will produce a reformatted volume where the slices of the straightened volume are almost what I want, except that it requires a curve as input (rather than just a point and vectors), does not allow control of the viewUp vector (I assume because it is calculated automatically from the curve?), and outputs a volume rather than a single image array.
What I want to be able to do is obviously exactly what is happening in slice viewers when in reformat mode, but I have not been able to find the code which actually does the resampling work based on the inputs, probably because I have trouble following C++ code around in the Slicer GitHub repository. I see things like vtkSlicerReformatLogic::SetSliceNormal() which seems related, but it’s more modifying the state of a continuously existing object (a slice node I think) than linking a specific set of inputs to a specific resampled image output slice, which is what I am trying to do.
Both of these examples (the Reformat and CurvedPlanarReformat modules) make it seem like what I want is probably already doable within Slicer without me trying to write code from scratch to do the resampling I want, but I could use some help figuring out how to use or modify the existing tools. Thanks for any help you can provide!