Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Analysis & Postprocessing
  4. How do I export multiple MATLAB files together?

How do I export multiple MATLAB files together?

Scheduled Pinned Locked Moved Analysis & Postprocessing
8 Posts 3 Posters 136 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gotou
    wrote on last edited by
    #1

    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?
    スクリーンショット 2025-01-17 134453.png

    1 Reply Last reply
    0
    • brynB Offline
      brynB Offline
      bryn
      ZMT
      wrote last edited by
      #2

      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.

      L 1 Reply Last reply
      0
      • brynB bryn

        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.

        L Offline
        L Offline
        lucky_lin
        wrote last edited by
        #3

        @bryn
        Can GPU acceleration or multithreading parallel processing be used for post-processing with scripts?

        L 1 Reply Last reply
        0
        • brynB Offline
          brynB Offline
          bryn
          ZMT
          wrote last edited by bryn
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • L lucky_lin

            @bryn
            Can GPU acceleration or multithreading parallel processing be used for post-processing with scripts?

            L Offline
            L Offline
            lucky_lin
            wrote last edited by lucky_lin
            #5

            @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?

            1 Reply Last reply
            0
            • brynB Offline
              brynB Offline
              bryn
              ZMT
              wrote last edited by
              #6

              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.
              L 1 Reply Last reply
              0
              • brynB bryn

                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.
                L Offline
                L Offline
                lucky_lin
                wrote last edited by
                #7

                @bryn I want to save the TI field as an npy file to serve as the input for a neural network. Would using a different file format be faster?

                1 Reply Last reply
                0
                • brynB Offline
                  brynB Offline
                  bryn
                  ZMT
                  wrote last edited by bryn
                  #8

                  You could probably export (XPostProcessor.VtkExporter or XPostProcessor.VtkXmlExporter, not sure it is in s4l_v1) it as a VTK file and modify your neural network DataLoader to support VTK files, e.g., via the meshio package or the much larger vtk 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))

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Search