Skip to content

hedjour/med_to_csv

Repository files navigation

Contributors Forks Stargazers Issues GPLv3.0 License Documentation Status DOI

/docs/img/intro_light.png

/docs/img/intro_dark.png

MedAssociates to CSV file

A simple way to parse MedAssociate output file in tidy data :

  • 1 row = 1 observation
  • 1 col = 1 var

Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

About The Project

This program parses MedAssociates data files and transforms them into tidy csv files, containing the information selected by the user.

(back to top)

Built With

(back to top)

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

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

Installation

  1. Clone the repository

    git clone https://sourcesup.renater.fr/anonscm/git/medanalysis/medanalysis.git
  2. Install the required packages

    pip install numpy argparse yaml pandas
    pip install Gooey  # For graphical interface
    cd path/to/directory_of_git_clone
  3. Then run one of the two lines below:

    python setup.py install
    python setup.py install --user  # For windows users

    Or:

    pip install .

Installation on Linux — other method

Prerequisites:

  • A Linux system with sudo privileges
  • The latest release of med_to_csv downloaded from the Releases page
Steps
  1. 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_linux
  2. Move the executable to /usr/local/bin:

    sudo mv ~/Downloads/portable_med_to_csv_gui_linux /usr/local/bin/
  3. Download and set up the application icon:

    Download the config_icon.png file from the source and run:

    sudo mv config_icon.png /usr/share/icons/med_to_csv_icon.png
  4. 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
  5. Set the correct permissions for the desktop file:

    sudo chmod 644 /usr/share/applications/med_to_csv.desktop

(back to top)

Make Executable (Portable)

To make a GUI onefile executable, run these commands in terminal:

cd path/to/directory_of_git_clone
pyinstaller build_gui.spec

To make a CLI onefile executable, run these commands in terminal:

cd path/to/directory_of_git_clone
pyinstaller build_cli.spec

Data Organisation

The 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.

Example of data organisation for batch run

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

Example

Graphical User Interface

Run the application and follow the steps on the interface:

./main_gui

Command Line Interface

The 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_file

Warning

Your path must contain only ASCII characters (no accented characters such as: éèàï).

Config file

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.

  1. There are three types of parameters:

    • info_col : One column file
    • info_lab : Annotated file
    • options : Further options
  2. 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
  3. Options:

    • remove_zero_ending : True or False to 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.

  4. 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.

(back to top)

Roadmap

  • 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.

(back to top)

FAQ

If you get the following error:

A problem has occurred while processing the data: local variable 'lab_folder' referenced before assignment

Have you filled your sub-directories with MedAssociates output files?

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GPL v3.0 License. See LICENSE.txt for more information.

(back to top)

Contact

Project Link: https://github.com/hedjour/med_to_csv

(back to top)

Acknowledgments

(back to top)

About

A simple way to parse MedAssociate output file in tidy data

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors