Add-Ons¶
Add-Ons
Overview: Add-ons are small Python programs that extend PASTA-ELN's functionality. Researchers can develop or adopt these tools and share them. Add-ons are categorized into Extractors and other add-ons. Access them via "Configuration" > "Project Group" to specify their location.
Extractor add-ons¶
Extractors generate metadata when scanning projects or dropping files into folders. They provide:
Thumbnails for curation and annotation.
User-metadata for post-processing.
Vendor-metadata detailing instrument settings.
Links to instruments or procedures.
Metadata categories¶
metaVendor contains metadata read from the original data file and provided
by the scientific instrument or its vendor, such as acquisition settings.
metaUser contains metadata derived by the extractor that is useful for
interpreting the scientific data, such as tensile strength. Technical
provenance is stored separately in the database.
PASTA-ELN includes extractors for CSV, JPEG, JSON, MD, and PNG files. PNG and JPEG extractors serve as examples for custom development.
Testing and Optimizing Extractors¶
To test an extractor interactively, include the following code at the end of the extractor file:
from pathlib import Path
if __name__ == '__main__':
reply = use(Path('datafile.abc'), {'main': ''}, print)
print('User meta:', reply['metaUser'])
print('Vendor meta:', reply['metaVendor'])
Remove these lines before deployment.
Saving exported figures¶
An extractor receives a Path as filePath, a style dictionary, and
PASTA-ELN's saveFigure callback, i.e. ordinary print in the case above. Do not write figures directly with
plt.savefig or image.save.
PASTA_ELN_EXTRACTOR_API = 2
def use(filePath, style, saveFigure):
# Matplotlib: save the current figure
saveFigure()
# Pillow: save this image
saveFigure(image)
saveFigure supports PNG, JPEG, and SVG. It marks exported figures so
PASTA-ELN does not add them again during a scan.
Troubleshooting Extractor Issues¶
Python Errors: Ensure required libraries are installed. Use pip install <library_name> to resolve missing dependencies.
Metadata Errors: Store metadata as key-value dictionaries. Test with json.dumps() to identify issues.
import json
meta_vendor = {"detector": {"calibration_a": 4, "calibration_b": 1}, "settings": "high"}
try:
json.dumps(meta_vendor)
except Exception e:
print(e)
Matplotlib Image Conversion: Convert Matplotlib axes to SVG:
from io import StringIO
figfile = StringIO()
plt.savefig(figfile, format="svg")
image = figfile.getvalue()
Pillow Image Conversion: Convert Matplotlib axes to base64-encoded images:
from io import BytesIO
import base64
figfile = BytesIO()
image.save(figfile, format="PNG")
image_data = base64.b64encode(figfile.getvalue()).decode()
image = "data:image/png;base64," + image_data
File Format Information and Extractor Development¶
Understanding file formats is crucial for developing extractors. Refer to:
[Wikipedia: List of filename extensions](https://en.wikipedia.org/wiki/List_of_filename_extensions_(alphabetical))
[Wikipedia: Chemical file formats](https://en.wikipedia.org/wiki/Chemical_file_format)
[Wikipedia: List of file formats](https://en.wikipedia.org/wiki/List_of_file_formats)
Other Add-ons¶
Other add-ons enhance functionality and may include API keys for external services.
Project Add-ons¶
Generate reports, presentations, and drafts for scientific papers using the project's hierarchical structure. A default example includes a customizable HTML-based report.
Table Add-ons¶
Process data from tables:
Extract data directly from tables.
Use filenames from table items to generate scientific graphs.