Search code examples
rdm-script

How to transfer (to connect) data between Digital Micrograph and R


I'm a new DM's user and I need to transfer data (pixels bright) between Digital Micrograph and R, for processing and modelling an image.

Specifically, I would need to extract the bright pixels from an original image, send it to R for processing, and return to DM for to represent the new image.

I would like to know if it is possible and how to do it from an script in DM.

A lot of thanks. Regards.


Solution

  • There is very little direct connection between DM (scripting) and the outside world, so the best solution is quite likely the following (DM-centric) route:

    A script is started in DM, which does:

    • all the UI needed
    • extract the intensities etc.
    • save all required data in a suitable format on disc at specific path. (Raw data/text-data/...)
    • call an external application ( anything you can call from a command prompt, including .bat files) and waits until that command has finished

    Have all your R code been written in a way that it can be called from a command prompt, potentially with command prompt parameters (i.e. a configuration file):

    • read data from specific path
    • process as required (without an UI, so do it 'silently')
    • save results on disc on specific path
    • close application

    At this point, the script in DM continues, reading in the results (and potentially doing some clean-up of files on disc.)


    So, in essence, the important thing is that your R-code can work as a "stand-alone" black-box executable fully controlled by command-line parameters.

    The command you will need to launch an external application can be found in the help-documentation under "Utility Functions" and is LaunchExternalProcess. It has been introduced with GMS 2.3.1.