TRIOS Software and JSON Export: Overview of JSON Export from TRIOS Software and Import into Python

Keywords: TRIOS, JSON, Python

TB105

Abstract

This technical brief introduces the JSON file export feature in the TRIOS™ Software and explains how to import and work with these files in Python®. It serves as an introductory guide, with references to official documentation for more detailed information.

Note: The exported JSON file used in this technical brief can be downloaded here.

Introduction

The TRIOS Software instrument control and data analysis package offers numerous features for both routine and in-depth analysis of scientific data. However, you may sometimes need to generate uniform plot formats, overlay data from multiple sources, or apply advanced functions not available within TRIOS.

Previously, TRIOS could export data in formats such as plain text (ASCII), CSV, and Excel™ workbooks. Version 5.8 introduced the ability to export data as JavaScript™ Object Notation (JSON) files. JSON is a text-based, language-independent format that can be utilized in various programming and data-handling languages, and it is easily readable [1]. The JSON export follows a publicly available schema, ensuring consistent data structure and allowing code reuse across multiple samples run under the same procedure.

Typical packages used to work with JSON files include MATLAB, Python, R, and Julia. The format also allows flexibility for export to Laboratory Information Management Systems (LIMS).

Python Library for JSON Files

TA Instruments™ has created a Python library called TADataKit (available on GitHub) [2] specifically for working with TRIOS Software JSON export files. This library facilitates the generation of pandas DataFrames within Python, which can then be accessed as needed. Given Python’s wide availability, extensive libraries (including TADataKit), and the open-source nature of most tools, this guide focuses on Python and its usefulness. TADataKit requires Python version 3.8 or above. Python can be downloaded and installed from python.org, which also offers a wealth of information. Additionally, any libraries you plan to use must be installed before their use. Common libraries include Matplotlib for data visualization, pandas for data handling, and NumPy, SciPy, and LMFit for numerical analysis and curve fitting.

Exporting JSON Files From Trios Software

There are several ways to export JSON files from TRIOS Software:

  1. Manual Export: Through the file export options (Figure 1).
  2. Automatic Export: At the end of an experiment or when saving an analyzed data file (Figure 2).
  3. Batch Processing: Exporting multiple files at once (Figure 3).
Figure 1. Manual export to JSON file
Figure 1. Manual export to JSON file
Figure 2. Settings for automatic export
Figure 2. Settings for automatic export

Importing JSON Files Into Python

Once Python is installed, you can start coding immediately, though it may not be as beginner-friendly as desired. Several Integrated Development Environments (IDEs) are available for Python, with Jupyter® being a recommended option due to its clean layout and ease of use. Jupyter allows code to be written and executed in blocks, and it provides a straightforward way to copy and paste visual exports.

Figure 3. Export to JSON through batch processing
Figure 3. Export to JSON through batch processing

Example: Importing DSC Data

In this example, Differential Scanning Calorimetry (DSC) data from a Polylactic Acid sample experiment is imported, which includes the following steps:

  1. Equilibrate at 0.00 °C
  2. Ramp at 10.00 °C/min to 200.00 °C
  3. Isothermal for 2.0 min
  4. Ramp at 10.00 °C/min to 0.00 °C
  5. Ramp at 10.00 °C/min to 200.00 °C

Typically, required libraries and functions are imported at the top of the script. For importing the JSON file, first the experiment class from TADataKit is imported and then the JSON file can be loaded. This is shown in the following two lines of Python code:

This can be brought into a dataframe. There are two ways to achieve this:
1. Single DataFrame: Import the entire JSON file into one dataframe, which can then be subdivided as needed:

In this case, pla_df is the dataframe created. The “processed” statement indicates we are taking data with post-acquisition signal generation.

2. Subdivided DataFrames: Create separate dataframes for each experimental step:

This creates a dataframe where each step is already subdivided:

  • pla_df[0] is the Equilibrate step
  • pla_df[1] is the Ramp to 200.00 °C step
  • pla_df[2] is the Isothermal step
  • pla_df[3] is the Ramp to 0.00 °C step
  • pla_df[4] is the Ramp to 200.00 °C step

Python uses zero indexing, so the first item is line 0. You can print this list as a reminder:

To create a new dataframe for a particular step:

This creates a dataframe called heat_df containing the first heat data.

Conclusion

This technical brief provides a basic introduction to JSON file export from TRIOS Software and import into Python.

Acknowledgement

This technical brief was written by Philip Davies, Principal Applications Scientist (Thermal Analysis)

For more information or to request a product quote, please visit www.tainstruments.com to locate your local sales office information.

Python is a registered mark of Python Software Foundation. Excel is a trademark of Microsoft Corporation. JavaScript is a trademark of Oracle Corporation. pandas, Matplotlib, NumPy, and SciPy are trademarks of NumFOCUS, Inc. Jupyter is a trademark of LF Charities, of which Project Jupyter is a part. TRIOS and TA Instruments are trademarks of Waters Technologies Corporation.

Contact us to learn more about our instrumentation and how it can benefit your research.