A simple way to parse MedAssociate output file in tidy data :
- 1 row = 1 observation
- 1 col = 1 var
View Demo · Report Bug · Request Feature
This program parses MedAssociates data files and transforms them into tidy csv files, containing the information selected by the user.
To get a local copy up and running follow these simple steps.
This is an example of how to list things you need to use the software and how to install them.
pip
pip install numpy argparse pyaml pandas pip install Gooey # For graphical interface
Clone the repository
git clone https://sourcesup.renater.fr/anonscm/git/medanalysis/medanalysis.git
Install the required packages
pip install numpy argparse yaml pandas pip install Gooey # For graphical interface cd path/to/directory_of_git_clone
Then run one of the two lines below:
python setup.py install python setup.py install --user # For windows usersOr:
pip install .
Prerequisites:
- A Linux system with
sudoprivileges - The latest release of
med_to_csvdownloaded from the Releases page
Make the executable file runnable:
Open a terminal and navigate to your Downloads folder. Run the following command:
chmod +x ~/Downloads/portable_med_to_csv_gui_linuxMove the executable to
/usr/local/bin:sudo mv ~/Downloads/portable_med_to_csv_gui_linux /usr/local/bin/Download and set up the application icon:
Download the
config_icon.pngfile from the source and run:sudo mv config_icon.png /usr/share/icons/med_to_csv_icon.png
Create a desktop entry:
sudo bash -c 'cat > /usr/share/applications/med_to_csv.desktop' << 'EOF' [Desktop Entry] Type=Application Name=med_to_csv Comment=Data Processing and Wrangling in Python Icon=/usr/share/icons/med_to_csv_icon.png Exec=/usr/local/bin/portable_med_to_csv_gui_linux Terminal=false StartupNotify=false Categories=Science;MedicalSoftware;X-DataProcessing; StartupWMClass=python EOF
Set the correct permissions for the desktop file:
sudo chmod 644 /usr/share/applications/med_to_csv.desktop
To make a GUI onefile executable, run these commands in terminal:
cd path/to/directory_of_git_clone
pyinstaller build_gui.specTo make a CLI onefile executable, run these commands in terminal:
cd path/to/directory_of_git_clone
pyinstaller build_cli.specThe file is just an output of MedAssociate software. The path directory can contain sub-directories of sessions that contain the raw data files, or just MedAssociate files directly.
Warning
Your raw data directories must only contain MedAssociate output files.
Note
Experiment directory/
├── dir 01/
│ ├── file_med_associates_to_compil
│ ├── file_med_associates_to_compil
│ └── file_med_associates_to_compil
└── dir 02/
├── file_med_associates_to_compil
├── file_med_associates_to_compil
└── file_med_associates_to_compil
Or:
Experiment directory/ ├── file_med_associates_to_compil ├── file_med_associates_to_compil └── file_med_associates_to_compil
Run the application and follow the steps on the interface:
./main_guiThe software runs on the experiment directory that contains the directories containing the raw data files, or on the file itself, and returns a CSV file:
./main_cli.py path_to_medassociate_file config_file.yml output_csv_fileWarning
Your path must contain only ASCII characters (no accented characters such as: éèàï).
The config file is a necessary file that specifies the setup of your data to the software.
You can find an example in the config.yml file which contains all possibilities of setup.
You can mix 1-column file directories and annotated directory files in the experiment directory.
There are three types of parameters:
info_col: One column fileinfo_lab: Annotated fileoptions: Further options
For the first two types of parameters, indicate the information in this format:
Key : Value- Keys are the column names that you want in the output file.
- Values are:
- for
infos_col: row number - 1 (start index: 0) - for
infos_lab: letters used in the MedAssociate exercise - for
infos_opt: see next point
- for
Options:
remove_zero_ending:TrueorFalseto keep or remove zeros at the end of arrays.Cut: for cutting an output on a special character (usually a dot) into 2 columns.The value must be a list of lists of 4 elements:
- key to cut
- separator (usually the dot character)
- column name of the first sub-element
- column name of the second sub-element
Eval: for some columns whose values must be the result of a Python command
(e.g. to get information from a path). Must be a Python dictionary with the key as column name and the value as a short command string.
The following keys are MedAssociate keywords, only usable with annotated files:
- Start Date (automatically added)
- End Date
- Subject
- Experiment
- Group
- Box
- Start Time (automatically added)
- End Time
- MSN: MedAssociate exercise names
Note
Templates are available in the config.yml file.
- Add possibility for annotated file to not specify the YAML file and use YAML in parameter path with the same names as MPC names obtained from MSN.
If you get the following error:
A problem has occurred while processing the data: local variable 'lab_folder' referenced before assignmentHave you filled your sub-directories with MedAssociates output files?
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have any suggestion that would improve this software, please fork the repository and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GPL v3.0 License. See LICENSE.txt for more information.
- Jean-Emmanuel Longueville - jean.emmanuel.longueville@univ-poitiers.fr
- Myriam Hanna - myriam.hanna@univ-poitiers.fr
- Marcello Solinas
Project Link: https://github.com/hedjour/med_to_csv
- IRESP: This work was supported by a grant from the IRESP « IRESP-19-ADDICTIONS-20 » to MS
- LNEC
- Université de Poitiers
- INSERM
- Logo FreeVector.com
- Thanks to our old contributors: Ekter, Myriam Hanna.

