How do I export multiple MATLAB files together?
-
I am currently exporting EM potentials for various parts of the human body in MATLAB using the "Imp/Export" menu and the "MATLAB Exporter," but the large number of exports is taking a significant amount of time as I have to do them one by one. Is there a way to export them all at once?
-
The easiest is to write a Python script. To learn how to write the script, I would first select one of the exporters, right-click to get the context menu, and select "To Python Script" (or similar). You can then modify the script to iterate over all fields, saving each to a separate file.
-
The easiest is to write a Python script. To learn how to write the script, I would first select one of the exporters, right-click to get the context menu, and select "To Python Script" (or similar). You can then modify the script to iterate over all fields, saving each to a separate file.
-
@bryn
Can GPU acceleration or multithreading parallel processing be used for post-processing with scripts?@bryn I want to export the TI electric field to a txt file, but each file is too large, and the number of digits for each electric field value is quite high, making the export process time-consuming. Is there a way to modify the number of digits in the exported data and choose to export only the electric field values without the coordinate points?
-
The exporter currently has no option to set the precision. While this could be something we can add for an upcoming version, the text export will always be slow and create big files. It is simply not optimal.
I guess you are exporting to .txt so you can process it in another tool? Which tool, or how do you want to use it downstream?
Other options could be:
- export to vtk (binary) format, or one of the XML vtk formats like .vtr. Many tools and libraries can read vtk files.
- access the field as numpy array in python and export as whatever, e.g., .mat, .npz, as binary files, or csv (with your own formatting), etc.
-
The exporter currently has no option to set the precision. While this could be something we can add for an upcoming version, the text export will always be slow and create big files. It is simply not optimal.
I guess you are exporting to .txt so you can process it in another tool? Which tool, or how do you want to use it downstream?
Other options could be:
- export to vtk (binary) format, or one of the XML vtk formats like .vtr. Many tools and libraries can read vtk files.
- access the field as numpy array in python and export as whatever, e.g., .mat, .npz, as binary files, or csv (with your own formatting), etc.
-
You could probably export (
XPostProcessor.VtkExporter
orXPostProcessor.VtkXmlExporter
, not sure it is ins4l_v1
) it as a VTK file and modify your neural network DataLoader to support VTK files, e.g., via themeshio
package or the much largervtk
package, or many others.Or you could write a little Python script to grab the field data and save it to npy. To access the field, you would get the output of the extractor or pipeline entity in the analysis, say a FloatFieldData object. It has a
Field(self, index: int) -> np.ndarray
method to get the field as a numpy array, which you could save using e.g.,np.save("filename.npy", fd.Field(0))