after apply_inverse(), How to save my data into a .vtk with time series?

Now I visualze my data through:

stc_suf = apply_inverse(evoked, inv, lambda2, inv_method)
stc_suf.plot(surface='pial', subjects_dir=subjects_dir, hemi='both', initial_time=initial_time)
mlab.show()

I want to save this 3d- time series into a single .vtk file, however there are two difficulties can not be solved:
1: I can’t seperate ‘stc_suf’ into x,y,z axis, but it is needed in vtk_data.SetDimensions(data.shape)
2: How can I switch my data after ‘apply_inverse’ to the shape witch is supported for this (to the variable ‘data shape’ which can be load by vtk_data.SetDimensions, which needs 3 demention):

vtk_data = vtkStructuredPoints()
vtk_data.SetDimensions(data.shape)
vtk_data.SetOrigin(x.min(), y.min(), z.min())
vtk_data.SetSpacing((x[1]-x[0]), (y[1]-y[0]), (z[1]-z[0]))
vtk_data.GetPointData().SetScalars(data.ravel(order='F'))
time_series = np.sin(np.linspace(0, 2*np.pi, 10))
vtk_data.GetFieldData().AddArray(time_series)

Thanks so much for the anwsering!

cc @larsoner. Would you like to have a look at this?

best,
Dip

I think that’s more a VTK question than a MNE one. At the end of the day in MNE you can get a triangulated mesh (vertices and triangles) and values at the vertices that vary as a function of time. The question is what is the best way to export data in this format to VTK. This will be different from data defined on a volumetric grid, which seems more like where you’re headed with the existing code (?).

1 Like

Sorry I didn’t get the message until now, yes you are right, is there any way to switch a data shape (n_dipoles, n_times), to a .vtk file or gltf file?