{ "info": { "author": "Ben Acland", "author_email": "benacland@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Topic :: Scientific/Engineering :: Information Analysis" ], "description": "Varys\n=====\n\nVarys is a python package for anyone who has to work with behavioral\ndata logs.\n\nChances are, you need that data in another format before you can work\nwith it. If you're like most of us, you have some collection of scripts\naround somewhere that can parse format A, other scripts that write\nformat B, and somewhere in the middle you'll sandwich some logic that\nactually has something to do with your experiment.\n\nOur goal is to reduce the load down to this last bit.\n\nVarys breaks its work into three segments: LogParser, EventBuilder, and\nFileWriter. Of these, only EventBuilder needs to be customized per\nexperiment.\n\nLogParser is meant to grow with time to be able to parse an increasingly\ndiverse list of input types. At the moment we support simple TDF and CSV\nformats, as well as the FIDL format used by the eponymous software\npackage from Washington University in St Louis. But we're willing and\ninterested to work with users to expand that list.\n\nEventBuilder takes input from a LogParser, and turns it into a list of\n\"event\" dictionaries. These can contain arbitrary values, but at a\nminimum must contain \"name,\" \"onset\" and \"duration.\"\n\nFileWriter takes these ordered dictionaries, then writes files\nconsumable by analysis packages. At the time of this writing, we support\nSPM, FIDL, tab delimited .txt, and python's Pickle, but here again we're\nwilling and eager to expand the list of supported formats.\n\nWe've thrown in some special options for working with neuroimaging data,\nfor concatenating runs, and other fun stuff too.\n\nSo please, take a look at the examples list, see if any of them sound\nlike your situation, and feel free to use them as a starting point for\nyour own work.\n\nInstallation\n============\n\nVarys uses scipy, which in turn uses numpy, and as of yet we're too lazy\nto do the fancy dancing needed to auto-install numpy as a dependency. So\nit'll take two steps:\n\n::\n\n pip install numpy\n pip install varys\n\nOr grab the latest development version from\nhttps://github.com/beOn/varys, and install using setup.py.\n\nSupported Formats\n=================\n\nCurrently supported formats are:\n\nInput: .txt, .tdf, .csv, .fidl\n\nOutput: spm, fidl, pickle, txt (tab delimited)\n\nExamples\n========\n\nVarys provides several EventBuilder subclasses for handling data in\ndifferent ways - in short, you can either have your data handed to you\nas a list of rows (as dicts), or you can have it handed to you one row\nat a time. Usually the latter approach is the most helpful.\n\nThere are several EventBuilder subclasses you can dive into, but here\nwe'll cover the kinds you're most likely to use: RowWise\\_EventBuilder,\nRowWise\\_fMRI\\_EventBuilder, and FixedDuration\\_EventBuilder. Please\nforgive the long names. Names were never my strong suit.\n\nUsing either of the two RowWise classes involves creating your own\nsubclass, whereas FixedDuration\\_EventBuilder is meant to be configured\nand used without subclassing, making it easier to write very simple\nEventBuilders.\n\nEnough chit chat. Let's look at some examples.\n\nMise en Sc\u00e8ne\n-------------\n\nFor the following examples, we'll pretend that a few things are the\ncase:\n\n- Subject data is in /data/sub\\_N/run\\_M.txt, where 'N' and 'M' are\n two-digit subject and run numbers, respectively (ie 01, 02, etc.).\n- The event name is whatever value is stored in the column named\n \"trial\\_type\"\n- All trials have a duration of 10.0\n- Trial onset time is in a column named 'cue\\_onset'\n- Answer accuracy is in a column named \"acc\", and is either '1' or '0'.\n- The first trial's onset time is to be used as time = 0\n- For the fMRI subclass, the TR is .7, because your scanner is awesome\n (written circa 2014)\n- For the sake of clarity, we're going to be sloppy about not catching\n exceptions.\n- Each run's data is in its own file\n- You have three subjects, 1, 2, and 3\n- You want to save the resulting files into \"/data/output\"\n- Your source files fall into the correct order if sorted\n alphabetically\n- You want to use the events in SPM, and save a pickled version as well\n for later use in python\n\nRowWise\\_EventBuilder\n---------------------\n\nThis is probably the most useful subclass, and is pretty simple. Let's\ntake a look.\n\n.. code:: python\n\n from varys.EventBuilder import RowWise_EventBuilder\n class basic_EventBuilder(RowWise_EventBuilder):\n def __init__(self):\n super(basic_EventBuilder, self).__init__()\n self.trial_onset = 0\n self.data_glob_templates = [\"/data/sub_%02d/run_*.txt\"]\n self.subjects = [1,2,3]\n self.output_dir = \"/data/output\"\n self.output_formats = [\"spm\", \"pickle\"]\n def events_for_row(self, row_dict):\n events = []\n name = row[\"trial_type\"]\n onset = float(row[\"cue_onset\"]) - self.trial_onset\n acc = row[\"acc\"]\n if name and onset:\n events.append([\"name\":name,\n \"onset\":onset,\n \"duration\":10.0,\n \"acc\":acc,\n \"set\":\"all_events\"])\n return events\n def handle_run_start(self, run_idx, run_data, file_name):\n self.trial_onset = float(run_data[0][\"cue_onset\"])\n\n eb = basic_EventBuilder()\n eb.run()\n\nTo get the details on this and the other subclasses, check out the noted\nin the related code. But since we're here, let's take this apart a\nlittle bit.\n\n``handle_run_start`` gets called at the start of every run, and as such\nis a great place to find and set aside any run-wide variables, like run\nonset time. That's exactly what we do in this example.\n\n``events_for_row`` gets called once per row of data in your original\nfile, and is expected to return a list of dicts (one dict per event).\nYou might be wondering what this set entry is all about, and why we\nreturn a list of events, instead of just one. From time to time,\nanalysis will require that you create several different event sets - one\nincluding all trials, and one including only those trials which were\nanswered correctly, for example. Suppose we wanted to do exactly this\nfor the current example. Then we'd change the if block of\nevents\\_for\\_row to read as follows:\n\n.. code:: python\n\n if name and onset:\n events.append([\"name\":name,\n \"onset\":onset,\n \"duration\":10.0,\n \"acc\":acc,\n \"set\":\"all_events\"])\n if acc == \"1\":\n events.append([\"name\":name,\n \"onset\":onset,\n \"duration\":10.0,\n \"acc\":acc,\n \"set\":\"acc_events\"])\n\nNote that we used a different ``set`` for the second event. This will\ncause EventBuilder to write two sets of files for the two event sets.\nYou might not need this, but if you do, it sure is nice not to have to\nwrite a whole 'nother subclass!\n\nThe ``init`` method just presets a few values specific to this\nexperiment. Note that you can override these. If you moved the script to\nanother machine, where the data was instead in\n``/my_data/subjects/sN/run_M.txt`` (remembering that N and M are\ntwo-digit subject and run numbers, respectively), and you wanted to save\nthe results to ``/analyses/new_data``, you don't have to modify the\nsubclass. You can just change a couple of values, then call ``run()``:\n\n.. code:: python\n\n eb = basic_EventBuilder()\n eb.data_glob_templates = [\"/my_data/subjects/s%02d/run_*.txt\"]\n eb.output_dir = \"/analyses/new_data\"\n eb.run()\n\n``subjects`` can be similarly changed.\n\nRowWise\\_fMRI\\_EventBuilder\n---------------------------\n\nThis class is pretty much the same as RowWise\\_EventBuilder, but has a\nfew extra features specific to fMRI. Let's take a look, and go through\nit afterwards. I'll omit everything that would be identical, but do\nremember to include it in your own subclasses.\n\n.. code:: python\n\n from varys.EventBuilder import RowWise_EventBuilder\n class basic_fMRI_EventBuilder(RowWise_EventBuilder):\n def __init__(self):\n super(basic_fMRI_EventBuilder, self).__init__()\n # same as RowWise_EventBuilder, with one extra property:\n self.TR = .7\n\n # events_for_row same as RowWise_EventBuilder\n # handle_run_start same as RowWise_EventBuilder\n\n def tr_count_for_run(self, run_idx, file_name, raw_rows, events):\n \"\"\" return the TR count for the given run. \"\"\"\n if run_idx < 2:\n return 130\n else:\n return 200\n\nSo, there are really only two differences here, and their utility might\nnot be immediately apparent (we'll get there): the property ``TR``, and\nthe method ``tr_count_for_run``. In this example, we set the TR to .7,\nand return one of two values for ``tr_count_for_run`` depending on the\nrun number.\n\nSo, who gives a flying leap at a rolling doughnut about TRs and how many\nthere are per run? Anyone who needs to concatenate their runs, that's\nwho. We use these two properties to figure out how much time to add to\nthe onset of all events for each run. So if you have 100 TRs of length\n.7 each in run 1, every event in run 2 will have 70.0 added to its onset\ntime. But take note, *this will only happen if you set the\n``concat_sets`` property to a list of the sets whose runs you'd like to\nconcatenate*. We do it this way because you may not want to concatenate\nruns for every event set. So, if we wanted to concatenate runs, but only\nfor the event set that contains accurate response events (acc\\_events),\nwe'd change the init method like so:\n\n.. code:: python\n\n def __init__(self):\n super(basic_fMRI_EventBuilder, self).__init__()\n # same as RowWise_EventBuilder, with one extra property:\n self.TR = .7\n self.concat_sets = [\"acc_events\"]\n\nTake note, some output formats, such as fidl, absolutely require\nconcatenated runs. If you specify one of these output formats, *all runs\nin all sets will be automatically concatenated*, even if you don't set\nconcat\\_sets.\n\nSkipping Output\n---------------\n\nSometimes, you don't actually want to write the event set out to any\nfile. You just want to parse the events, then keep working with them in\nyour code.\n\nTo do this, set the ``skip_output`` property to True, then retrieve the\nvalues for the subject you're interested in. Working with our\n``basic_EventBuilder``, if we wanted to get the list of lists of event\ndicts for subject 1, we'd do as follows:\n\n.. code:: python\n\n eb = basic_EventBuilder()\n eb.skip_output = True\n eb.run()\n sub_num = 1\n s1_events = eb.sub_data[sub_num][\"acc_events\"]\n\nOne Giant Input File\n--------------------\n\nIt may be the case that, instead of having one input file per run,\neverything's in one big table, and there's some column whose value\nchanges every time a new run's data begins. To handle this, just set the\n``run_field`` property to the name of that column. If this were the case\nfor our example, and the name of the column was \"run\\_number\", we'd just\nmake a slight modificaiton to the init method:\n\n.. code:: python\n\n class basic_EventBuilder(RowWise_EventBuilder):\n def __init__(self):\n super(basic_EventBuilder, self).__init__()\n # everything is the same as before, but add:\n self.run_field = \"run_number\"\n # everything else is the same as before\n\nNot so bad, eh?\n\nTODO\n----\n\n- FixedDuration\\_EventBuilder, once it's ready\n\nReporting Bugs, Requesting Features\n===================================\n\nSubmit all bug reports and feature requests using the github ticketing\nsystem: https://github.com/beOn/cili/issues\n\nPlease make an effort to provide high quality bug reports. If we get one\nthat just says, \"sample range extraction is broken,\" we'll probably\ntrash it without a second look, because the submitter is probably the\nkind of person who saps energy from everything they touch.\n\nA good bug report should include three things:\n\n1. Steps to reproduce the bug\n2. Expected result\n3. Actual result\n\nThe goal is to give the developers the ability to recreate the bug\nbefore their own eyes. If you can give us that, we'll take a very close\nlook.\n\nWhy Varys?\n==========\n\nBecause it manipulates events: http://gameofthrones.wikia.com/wiki/Varys\n\nTODO: Thanks, credit to CCP Lab", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/beOn/varys", "keywords": "behavioral", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "varys", "package_url": "https://pypi.org/project/varys/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/varys/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/beOn/varys" }, "release_url": "https://pypi.org/project/varys/0.5.2/", "requires_dist": null, "requires_python": null, "summary": "For parsing and reformatting behavioral event logs.", "version": "0.5.2" }, "last_serial": 1120990, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "7f156d4daeffbf14ecf04c733bad1ac7", "sha256": "7b146414118725b984304dfee0b53258266c61d85763ffd9771981ea0d059a13" }, "downloads": -1, "filename": "varys-0.5.0-py2.7.egg", "has_sig": true, "md5_digest": "7f156d4daeffbf14ecf04c733bad1ac7", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 39225, "upload_time": "2014-04-30T17:17:24", "url": "https://files.pythonhosted.org/packages/fa/ce/d650f38a31688dd4fac36d28219212dd3a18e6e90cb3b3fabb308dfeb5a8/varys-0.5.0-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "ebf3f19e7df90b693b26e30047ce7966", "sha256": "c15a0821701ebe898e3cc994fcded49597f04b2bf65f122b7c4b7a9da853f084" }, "downloads": -1, "filename": "varys-0.5.0.tar.gz", "has_sig": true, "md5_digest": "ebf3f19e7df90b693b26e30047ce7966", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9227, "upload_time": "2014-04-30T17:16:21", "url": "https://files.pythonhosted.org/packages/26/19/4af4b362f7731d067dc2899cc984d5e4c38ceb8463f5d7cfb00e9c211eda/varys-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "9142035ce957c2ae67be2071382fa57f", "sha256": "f8ab9a982272e8bc77147813a62824770bd9a11d3b03274a8b0e75e1be405e7a" }, "downloads": -1, "filename": "varys-0.5.1-py2.7.egg", "has_sig": true, "md5_digest": "9142035ce957c2ae67be2071382fa57f", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 26569, "upload_time": "2014-05-08T22:32:16", "url": "https://files.pythonhosted.org/packages/a9/17/b74446313ebec0343e0614104fa86b3e1c450f75f57c0ab424fbe9e33d14/varys-0.5.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "12521674e779ff9df36044b310261ece", "sha256": "d21bbad4fa91f05785bb473a6a6d77da75311d2f1d55b3a24932f2bd454d1b3d" }, "downloads": -1, "filename": "varys-0.5.1.tar.gz", "has_sig": true, "md5_digest": "12521674e779ff9df36044b310261ece", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17229, "upload_time": "2014-05-08T22:32:26", "url": "https://files.pythonhosted.org/packages/f1/a1/9af56dddbc8be3c0eea8bca79943f7eec6d8bae91c3ebc46996a2160fa72/varys-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "09e91179cf4d4fdd4a08d50af2c64aa1", "sha256": "72382ac96cb4d7ced5272ea9b60a0b66927870652f4001e992184c9a3bb8cbf3" }, "downloads": -1, "filename": "varys-0.5.2-py2.7.egg", "has_sig": true, "md5_digest": "09e91179cf4d4fdd4a08d50af2c64aa1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 26854, "upload_time": "2014-06-11T00:20:31", "url": "https://files.pythonhosted.org/packages/a3/da/03d78e14594fe77c106299aa75d3ded8038fc2471c9f48e16a25e8e672e5/varys-0.5.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "2e9803e453cda43b7424d93bc16bf848", "sha256": "69889ea302da264d94f67757c74bd1964471800792cb9d23e5725e5df62a594b" }, "downloads": -1, "filename": "varys-0.5.2-py2-none-any.whl", "has_sig": true, "md5_digest": "2e9803e453cda43b7424d93bc16bf848", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 19880, "upload_time": "2014-06-11T00:20:34", "url": "https://files.pythonhosted.org/packages/5c/92/0951113e63458541e5510747497e1a2dccb1ed4c422d1539edba8c7d68e7/varys-0.5.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9c517e687d91a8e343d0cced16b76c0e", "sha256": "39b81d5291147bd5f447ad0d618b62a66bceab6cdca2a4c23e38a3061674c047" }, "downloads": -1, "filename": "varys-0.5.2.tar.gz", "has_sig": true, "md5_digest": "9c517e687d91a8e343d0cced16b76c0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17400, "upload_time": "2014-06-11T00:20:29", "url": "https://files.pythonhosted.org/packages/08/2e/b52641f95ba4ce5553cfa9f4d3bb142c874e935d3474845552b65ad933cf/varys-0.5.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "09e91179cf4d4fdd4a08d50af2c64aa1", "sha256": "72382ac96cb4d7ced5272ea9b60a0b66927870652f4001e992184c9a3bb8cbf3" }, "downloads": -1, "filename": "varys-0.5.2-py2.7.egg", "has_sig": true, "md5_digest": "09e91179cf4d4fdd4a08d50af2c64aa1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 26854, "upload_time": "2014-06-11T00:20:31", "url": "https://files.pythonhosted.org/packages/a3/da/03d78e14594fe77c106299aa75d3ded8038fc2471c9f48e16a25e8e672e5/varys-0.5.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "2e9803e453cda43b7424d93bc16bf848", "sha256": "69889ea302da264d94f67757c74bd1964471800792cb9d23e5725e5df62a594b" }, "downloads": -1, "filename": "varys-0.5.2-py2-none-any.whl", "has_sig": true, "md5_digest": "2e9803e453cda43b7424d93bc16bf848", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 19880, "upload_time": "2014-06-11T00:20:34", "url": "https://files.pythonhosted.org/packages/5c/92/0951113e63458541e5510747497e1a2dccb1ed4c422d1539edba8c7d68e7/varys-0.5.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9c517e687d91a8e343d0cced16b76c0e", "sha256": "39b81d5291147bd5f447ad0d618b62a66bceab6cdca2a4c23e38a3061674c047" }, "downloads": -1, "filename": "varys-0.5.2.tar.gz", "has_sig": true, "md5_digest": "9c517e687d91a8e343d0cced16b76c0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17400, "upload_time": "2014-06-11T00:20:29", "url": "https://files.pythonhosted.org/packages/08/2e/b52641f95ba4ce5553cfa9f4d3bb142c874e935d3474845552b65ad933cf/varys-0.5.2.tar.gz" } ] }