mnetonix.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html><head><title>Python: module mnetonix</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. </head><body bgcolor="#f0f0f8">
  5. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
  6. <tr bgcolor="#7799ee">
  7. <td valign=bottom>&nbsp;<br>
  8. <font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>mnetonix</strong></big></big></font></td
  9. ><td align=right valign=bottom
  10. ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/achilleas/code/pilsen-workshop/DataConversionToNIX/mnetonix.py">/Users/achilleas/code/pilsen-workshop/DataConversionToNIX/mnetonix.py</a></font></td></tr></table>
  11. <p><tt>mnetonix.py<br>
  12. &nbsp;<br>
  13. Usage:<br>
  14. &nbsp;&nbsp;python&nbsp;mnetonix.py&nbsp;[--split-data]&nbsp;[--split-stimuli]&nbsp;&lt;datafile&gt;&nbsp;&lt;montage&gt;<br>
  15. &nbsp;<br>
  16. Arguments:<br>
  17. &nbsp;&nbsp;datafile&nbsp;&nbsp;&nbsp;Either&nbsp;an&nbsp;EDF&nbsp;file&nbsp;or&nbsp;a&nbsp;BrainVision&nbsp;header&nbsp;file&nbsp;(vhdr).<br>
  18. &nbsp;&nbsp;montage&nbsp;&nbsp;&nbsp;&nbsp;Any&nbsp;format&nbsp;montage&nbsp;file&nbsp;supported&nbsp;by&nbsp;MNE.<br>
  19. &nbsp;<br>
  20. Flags:<br>
  21. &nbsp;&nbsp;--split-data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;specified,&nbsp;each&nbsp;channel&nbsp;of&nbsp;raw&nbsp;data&nbsp;is&nbsp;stored&nbsp;in&nbsp;its&nbsp;own<br>
  22. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;separate&nbsp;DataArray.<br>
  23. &nbsp;<br>
  24. &nbsp;&nbsp;--split-stimuli&nbsp;&nbsp;&nbsp;If&nbsp;specified,&nbsp;each&nbsp;stimulus&nbsp;type&nbsp;(identified&nbsp;by&nbsp;its&nbsp;label)<br>
  25. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is&nbsp;stored&nbsp;in&nbsp;a&nbsp;separate&nbsp;MultiTag&nbsp;(one&nbsp;MultiTag&nbsp;per<br>
  26. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stimulus&nbsp;type).<br>
  27. &nbsp;<br>
  28. &nbsp;<br>
  29. (Requires&nbsp;Python&nbsp;3)<br>
  30. &nbsp;<br>
  31. Command&nbsp;line&nbsp;script&nbsp;for&nbsp;reading&nbsp;EDF&nbsp;and&nbsp;BrainVision&nbsp;files&nbsp;using&nbsp;MNE<br>
  32. (mne-python)&nbsp;and&nbsp;storing&nbsp;the&nbsp;data&nbsp;and&nbsp;metadata&nbsp;into&nbsp;a&nbsp;NIX&nbsp;file.&nbsp;&nbsp;Supports<br>
  33. reading&nbsp;montage&nbsp;files&nbsp;for&nbsp;recording&nbsp;channel&nbsp;locations.<br>
  34. &nbsp;<br>
  35. To&nbsp;include&nbsp;in&nbsp;a&nbsp;script,&nbsp;call&nbsp;the&nbsp;'<a href="#-write_raw_mne">write_raw_mne</a>()'&nbsp;and&nbsp;provide&nbsp;a&nbsp;NIX&nbsp;filename<br>
  36. and&nbsp;MNE&nbsp;Raw&nbsp;structure&nbsp;as&nbsp;arguments.<br>
  37. &nbsp;<br>
  38. NIX&nbsp;Format&nbsp;layout<br>
  39. =================<br>
  40. &nbsp;<br>
  41. Data<br>
  42. ----<br>
  43. Raw&nbsp;Data&nbsp;are&nbsp;stored&nbsp;in&nbsp;either&nbsp;a&nbsp;single&nbsp;2-dimensional&nbsp;DataArray&nbsp;or&nbsp;a&nbsp;collection<br>
  44. of&nbsp;DataArrays&nbsp;(one&nbsp;per&nbsp;recording&nbsp;channel).&nbsp;&nbsp;The&nbsp;latter&nbsp;makes&nbsp;tagging&nbsp;easier<br>
  45. since&nbsp;MultiTag&nbsp;positions&nbsp;and&nbsp;extents&nbsp;don't&nbsp;need&nbsp;to&nbsp;specify&nbsp;every&nbsp;channel&nbsp;they<br>
  46. reference.&nbsp;&nbsp;However,&nbsp;creating&nbsp;multiple&nbsp;DataArrays&nbsp;makes&nbsp;file&nbsp;sizes&nbsp;much<br>
  47. bigger.<br>
  48. &nbsp;<br>
  49. Stimuli<br>
  50. -------<br>
  51. MNE&nbsp;provides&nbsp;stimulus&nbsp;information&nbsp;through&nbsp;the&nbsp;Raw.annotations&nbsp;dictionary.<br>
  52. Onsets&nbsp;correspond&nbsp;to&nbsp;the&nbsp;'positions'&nbsp;array&nbsp;and&nbsp;durations&nbsp;correspond&nbsp;to&nbsp;the<br>
  53. 'extents'&nbsp;array&nbsp;of&nbsp;the&nbsp;"Stimuli"&nbsp;MultiTag.&nbsp;&nbsp;If&nbsp;stimulus&nbsp;information&nbsp;is&nbsp;split<br>
  54. by&nbsp;label,&nbsp;each&nbsp;MultiTag&nbsp;uses&nbsp;the&nbsp;label&nbsp;as&nbsp;its&nbsp;name.<br>
  55. &nbsp;<br>
  56. Metadata<br>
  57. --------<br>
  58. MNE&nbsp;collects&nbsp;metadata&nbsp;into&nbsp;a&nbsp;(nested)&nbsp;dictionary&nbsp;(Raw.info).&nbsp;&nbsp;All&nbsp;non-empty<br>
  59. keys&nbsp;are&nbsp;converted&nbsp;into&nbsp;Properties&nbsp;in&nbsp;NIX.&nbsp;&nbsp;The&nbsp;nested&nbsp;structure&nbsp;of&nbsp;the<br>
  60. dictionary&nbsp;is&nbsp;replicated&nbsp;in&nbsp;NIX&nbsp;by&nbsp;creating&nbsp;child&nbsp;Sections,&nbsp;starting&nbsp;with&nbsp;one<br>
  61. root&nbsp;section&nbsp;with&nbsp;name&nbsp;"Info".<br>
  62. &nbsp;<br>
  63. Some&nbsp;extra&nbsp;metadata&nbsp;is&nbsp;kept&nbsp;in&nbsp;the&nbsp;'_raw_extras'&nbsp;private&nbsp;member&nbsp;when&nbsp;loading<br>
  64. from&nbsp;EDF&nbsp;files.&nbsp;&nbsp;This&nbsp;seems&nbsp;to&nbsp;be&nbsp;missing&nbsp;from&nbsp;the&nbsp;'Info'&nbsp;dictionary&nbsp;in&nbsp;order<br>
  65. to&nbsp;keep&nbsp;it&nbsp;anonymous&nbsp;(missing&nbsp;keys&nbsp;are&nbsp;'subject_info',&nbsp;'meas_date',&nbsp;'file_id',<br>
  66. and&nbsp;'meas_id').&nbsp;&nbsp;The&nbsp;'_raw_extras'&nbsp;are&nbsp;also&nbsp;stored&nbsp;in&nbsp;the&nbsp;NIX&nbsp;file&nbsp;in&nbsp;a<br>
  67. separate&nbsp;Section&nbsp;with&nbsp;name&nbsp;"Extras".</tt></p>
  68. <p>
  69. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  70. <tr bgcolor="#aa55cc">
  71. <td colspan=3 valign=bottom>&nbsp;<br>
  72. <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
  73. <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  74. <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="mne.html">mne</a><br>
  75. <a href="nixio.html">nixio</a><br>
  76. </td><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
  77. <a href="os.html">os</a><br>
  78. </td><td width="25%" valign=top><a href="matplotlib.pyplot.html">matplotlib.pyplot</a><br>
  79. <a href="sys.html">sys</a><br>
  80. </td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
  81. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  82. <tr bgcolor="#eeaa77">
  83. <td colspan=3 valign=bottom>&nbsp;<br>
  84. <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
  85. <tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  86. <td width="100%"><dl><dt><a name="-create_md_tree"><strong>create_md_tree</strong></a>(section, values, block)</dt></dl>
  87. <dl><dt><a name="-create_stimulus_multi_tag"><strong>create_stimulus_multi_tag</strong></a>(stimtuples, block, mneraw, mtagname='Stimuli')</dt></dl>
  88. <dl><dt><a name="-main"><strong>main</strong></a>()</dt></dl>
  89. <dl><dt><a name="-plot_channel"><strong>plot_channel</strong></a>(data_array, index)</dt></dl>
  90. <dl><dt><a name="-separate_stimulus_types"><strong>separate_stimulus_types</strong></a>(stimuli)</dt></dl>
  91. <dl><dt><a name="-write_multi_da"><strong>write_multi_da</strong></a>(mneraw, block)</dt></dl>
  92. <dl><dt><a name="-write_raw_mne"><strong>write_raw_mne</strong></a>(nfname, mneraw, split_data_channels=False, split_stimuli=False)</dt><dd><tt>Writes&nbsp;the&nbsp;provided&nbsp;Raw&nbsp;MNE&nbsp;structure&nbsp;to&nbsp;a&nbsp;NIX&nbsp;file&nbsp;with&nbsp;the&nbsp;given&nbsp;name.<br>
  93. &nbsp;<br>
  94. :param&nbsp;nfname:&nbsp;Name&nbsp;for&nbsp;the&nbsp;NIX&nbsp;file&nbsp;to&nbsp;write&nbsp;to.&nbsp;Existing&nbsp;file&nbsp;will&nbsp;be<br>
  95. overwritten.<br>
  96. :param&nbsp;mneraw:&nbsp;An&nbsp;MNE&nbsp;Raw&nbsp;structure&nbsp;(any&nbsp;mne.io.BaseRaw&nbsp;subclass).<br>
  97. :param&nbsp;split_data_channels:&nbsp;If&nbsp;True,&nbsp;each&nbsp;raw&nbsp;data&nbsp;channel&nbsp;will&nbsp;be&nbsp;stored<br>
  98. in&nbsp;a&nbsp;separate&nbsp;DataArray.<br>
  99. :param&nbsp;split_stimuli:&nbsp;If&nbsp;True,&nbsp;stimuli&nbsp;will&nbsp;be&nbsp;split&nbsp;into&nbsp;separate<br>
  100. MultiTags&nbsp;based&nbsp;on&nbsp;the&nbsp;stimulus&nbsp;type&nbsp;(label).<br>
  101. :rtype:&nbsp;None</tt></dd></dl>
  102. <dl><dt><a name="-write_single_da"><strong>write_single_da</strong></a>(mneraw, block)</dt></dl>
  103. <dl><dt><a name="-write_stim_tags"><strong>write_stim_tags</strong></a>(mneraw, block, split)</dt></dl>
  104. </td></tr></table><p>
  105. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  106. <tr bgcolor="#55aa55">
  107. <td colspan=3 valign=bottom>&nbsp;<br>
  108. <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
  109. <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  110. <td width="100%"><strong>DATA_BLOCK_NAME</strong> = 'EEG Data Block'<br>
  111. <strong>DATA_BLOCK_TYPE</strong> = 'Recording'<br>
  112. <strong>RAW_DATA_GROUP_NAME</strong> = 'Raw Data Group'<br>
  113. <strong>RAW_DATA_GROUP_TYPE</strong> = 'EEG Channels'<br>
  114. <strong>RAW_DATA_TYPE</strong> = 'Raw Data'</td></tr></table>
  115. </body></html>