Click or drag to resize

Updating FileFormat plugins

To update a FileFormat Plugin separate the loaded data into either distinct ImpedanceSpectrum objects, which won't be split further by RelaxIS, and/or additional EISRawData objects. The latter can specify how the raw data list in it should be automatically split by RelaxIS. The finished spectra and raw data objects combined and returned in a FileFormatResult object.

The basic structure of FileFormat plugins was not changed. RelaxIS still calls the IdentifyFile(Stream) and GetData(Stream) functions.

However, the return type of the GetData(Stream) was changed to FileFormatResult .

This new object contains lists of ImpedanceSpectrum and EISRawData objects.

After loading the data RelaxIS will take the impedance spectra as-is without further processing. The EISRawData objects contain the functionality that was part of the old ImpedanceSpectrum_FileFormat class. That means that it contains a raw list of datapoints that will be further split into separate spectra by RelaxIS.

Prerequisites

Introduce using statements for the relevant namespaces.

C#
using RelaxIS_SDK.Common;
using RelaxIS_SDK.Common.FileFormat;
If the previous plugin returned one or more distinct spectra

Perform these steps to update the plugin

  1. Identify where previously individual data lists for frequency, real and imaginary parts, or an ImpedanceSpectrum_FileFormat were created.

    C#
    // BEFORE 3.0.23
    var frequencies = new List<double>();
    var realParts = new List<double>();
    var imagParts = new List<double>();
    // Or...
    var spectrum = new ImpedanceSpectrum_FileFormat();

    Replace this with the creation of a new ImpedanceSpectrum object.

    C#
    var spectrum = new ImpedanceSpectrum();
  2. Identify where previously the data read from the input was added to these lists.

    C#
    // BEFORE 3.0.23
    frequencies.Add(freq);
    realParts.Add(zreal);
    imagParts.Add(zimag);
    // Or...
    spectrum.Frequencies.Add(freq);
    spectrum.ZReal.Add(zreal);
    spectrum.ZImag.Add(zimag);

    Replace this with adding the data as new EISDatapoint objects to the spectrums Data property. You can use a suitable overload of the collection for simplification.

    C#
    spectrum.Data.Add(freq, zreal, zimag);
  3. Find where the data was returned as a list of ImpedanceSpectrum_FileFormat objects.

    C#
    // BEFORE 3.0.23
    var resSpectrum = new ImpedanceSpectrum_FileFormat(frequencies, realParts, imagParts);
    var res = new List<ImpedanceSpectrum_FileFormat>();
    
    res.Add(resSpectrum);
    // Or...
    res.Add(spectrum);
    
    return res;

    Replace this with returning a FileFormatResult object.

    C#
    var res = new FileFormatResult();
    res.Spectra.Add(spectrum);
    return res;
If the previous plugin returned a list that was automatically split by RelaxIS

Perform these steps to update the plugin

  1. Identify where previously individual data lists for frequency, real and imaginary parts, or an ImpedanceSpectrum_FileFormat were created.

    C#
    // BEFORE 3.0.23
    var frequencies = new List<double>();
    var realParts = new List<double>();
    var imagParts = new List<double>();
    // Or...
    var spectrum = new ImpedanceSpectrum_FileFormat();

    Replace this with the creation of a new EISRawData object.

    C#
    var data = new EISRawData();
  2. Identify where previously the data read from the input was added to these lists.

    C#
    // BEFORE 3.0.23
    frequencies.Add(freq);
    realParts.Add(zreal);
    imagParts.Add(zimag);
    // Or...
    spectrum.Frequencies.Add(freq);
    spectrum.ZReal.Add(zreal);
    spectrum.ZImag.Add(zimag);

    Replace this with adding the data as new EISMetaDatapoint objects to the objects Datapoints property. You can use a suitable overload of the collection for simplification.

    C#
    data.Datapoints.Add(freq, zreal, zimag);
  3. Metadata is handled on a per-point basis. After RelaxIS has split the data into individual spectra, the metadata of all points per spectrum is averaged to produce the final value.

    If you have read one metadata value applicable to all points, then add the same value to all datapoints. Alternatively add individual values per datapoint and rely on the averaging afterwards.

    The metadata is added as Metadata objects to the Metadata property of the datapoints, or added via an appropriate constructor

    C#
    var metadata = new MetadataCollection()
        {
            new Metadata("Temperature", 23.54),
        };
    data.Datapoints.Add(new EISDataPoint(freq, zreal, zimag), metadata);
    // Or...
    data.Datapoints.Add(freq1, zreal1, zimag1, new Metadata("Temperature", 23.54));
    data.Datapoints.Add(freq2, zreal2, zimag2, new Metadata("Temperature", 25.02));
  4. Define the splitting settings and behavior of the object. Which method you select depends on what the plugin was doing before.

    C#
    data.SplitOnDuplicateFrequencies = false;
    data.AutomaticSplitAfterSplitMode = false;
    
    // Select one of the available split methods
    data.SplitMode = SplitMode.Automatic;
    
    // Or...
    data.SplitMode = SplitMode.NumberOfPoints;
    data.NoDatapointsPerSpectrum = 35;
    
    // Or define a SplitValue for each datapoint when adding them to the list. Say the variable idx contains a spectrum index
    data.Datapoints.Add(new EISDatapoint(freq, zreal, zimag), idx);
    // ...
    data.SplitMode = SplitMode.BySplitValues;
  5. Find where the data was returned as a list of ImpedanceSpectrum_FileFormat objects.

    C#
    // BEFORE 3.0.23
    var resSpectrum = new ImpedanceSpectrum_FileFormat(frequencies, realParts, imagParts);
    var res = new List<ImpedanceSpectrum_FileFormat>();
    
    res.Add(resSpectrum);
    // Or...
    res.Add(spectrum);
    
    return res;

    Replace this with returning a FileFormatResult object.

    C#
    var res = new FileFormatResult();
    res.RawData.Add(data);
    return res;
See Also