danforthcenter / plantcv

Plant phenotyping with image analysis
Mozilla Public License 2.0
661 stars 265 forks source link

Help needed converting results into a spreadsheet #992

Closed Abree123 closed 1 year ago

Abree123 commented 1 year ago

Hi,

I am a undergrad student at University of Tennessee at Chattanooga working on phenotyping Helianthus spp. using your software. By looking at the morphology tutorials and watching some of the videos from your workshops on YouTube I have been able to create a workflow to find traits such as leaf number, height, and branching. I have been able to get the results, but I am unsure on how to convert the results file into a readable spreadsheet. I tried one of the methods I saw used in one of your YouTube videos to convert the results into a chart, and it did not work for me. I am not really sure if I even am using the right code, so I would greatly appreciate some help on how to convert my results.

Screen Shot 2023-01-03 at 2 56 15 PM
nfahlgren commented 1 year ago

Hi @Abree123, by default, PlantCV saves results in JSON format and that's what you are seeing when you run df.head(). JSON is required when running workflows in parallel. But it looks like you are wanting to load the results from a single image, so in your workflow, you can change the output format to CSV:

pcv.outputs.save_results(filename="results.txt", outformat="csv")

Pandas will then be able to read that file correctly.

If you end up running your workflow in parallel, you can convert the final output JSON file to CSV using our json2csv converter utility program: https://plantcv.readthedocs.io/en/stable/tools/#convert-output-json-data-files-to-csv-tables