Data preprocessing - Exporting IDyOM output data to other formats
py2lispIDyOM provides methods to export certain (or all) properties of the IDyOM outputs of selected (or all) melodies in different formats (.mat
and .csv
).
This tutorial will cover how to export outputs using py2lispIDyOM, given that you already have the .dat
file output. For an overview of the py2lispIDyOM functionality, see the README.
We will continue the sample example as in the 1_running_IDyOM_tutorial.ipynb, and extract some IDyOM outputs from that experiment, where the log folder is experiment_history/21-05-22_17.05.05/
[1]:
# import Export from export module
import py2lispIDyOM as py2lispIDyOM
from py2lispIDyOM.export import Export
1. Export outputs to .mat
formats
In this section, we will go over how to export the IDyOM outputs of melodies to .mat
files using the export2mat()
method.
1.1 Export selected outputs of selected melodies to .mat
In this example, we will export the melody_name
, cpitch
, and information.content
of the two melodies named ‘“chord-001”’ and ‘“chor-002”’ in the experiment 21-05-22_17.05.05
.
To check the available idyom_output_keywords
, please see the 2a_data_preprocessing_extracting tutorial.
[2]:
# define the parameters for the Export object
export_mat = Export(experiment_folder_path='experiment_history/21-05-22_17.05.05/',
idyom_output_keywords=['onset', 'cpitch', 'melody.name'],
melody_names=['"chor-001"', '"chor-002"'])
# export to .mat by calling the `export2mat()` method
export_mat.export2mat()
Exported data to experiment_history/21-05-22_17.05.05/outputs_in_mat/
Exported data to experiment_history/21-05-22_17.05.05/outputs_in_mat/
The output files are:
chor001_cpitch.mat
chor001_melody_name.mat
chor001_onset.mat
chor002_cpitch.mat
chor002_melody_name.mat
chor002_onset.mat
1.2 Export selected outputs of all melodies to .mat
To export selected outputs of all melodies, you don’t need to specify the melody_names
. If not specified, the selected properties of all melodies data will be exported, by default.
Here, we will export information.content
and entropy
of all the melodies in the experiment 21-05-22_17.05.05
.
[3]:
# define the parameters for the Export object
export_mat = Export(experiment_folder_path='experiment_history/21-05-22_17.05.05/',
idyom_output_keywords=['melody.name','information.content', 'entropy'])
# export to .mat by calling the `export2mat()` method
export_mat.export2mat()
Exported data to experiment_history/21-05-22_17.05.05/outputs_in_mat/
The output files are:
entropy.mat
information_content.mat
melody_name.mat
2. Export outputs to .csv
formats
In this section, we will go over how to export IDyOM outputs of melodies to .csv
files using the export2csv()
method.
In the current py2lispIDyOM version, export2csv()
only supports exporting all IDyoM outputs of selected or all melodies in the experiment.
The output will be a .csv
file containing all IDyOM outputs for each melody.
2.1 Export outputs of selected melodies to .csv
In this example, we will export the IDyOM outputs of the two melodies named ‘“chord-005”’ and ‘“chor-006”’ in the experiment 21-05-22_17.05.05
.
To check the available idyom_output_keywords
, please see the 2a_data_preprocessing_extracting tutorial.
[4]:
# define the parameters for the Export object
export_mat = Export(experiment_folder_path='experiment_history/21-05-22_17.05.05/',
melody_names=['"chor-005"', '"chor-006"'])
# export to .mat by calling the `export2mat()` method
export_mat.export2csv()
Exported data to experiment_history/21-05-22_17.05.05/outputs_in_csv/
The output files are:
chor-005.csv
chor-006.csv
2.2 Export outputs of all melodies to .csv
To export outputs of all melodies, simply leave the melody_names
argument as empty.
[ ]: