{
  "id": 10121,
  "title": "Open .mat file",
  "url": "/competitions/seizure-prediction/discussion/10121",
  "author_name": "",
  "post_date": "2014-08-26T22:42:11.630Z",
  "votes": 1,
  "comment_count": 14,
  "views": 4582,
  "content": "<p>Hi guys,</p>\n<p>I downloaded one .gz file and I extract it.&nbsp;</p>\n<p>Zip is asking me to name the extension.&nbsp;</p>\n<p>I am using .MAT but I cannot open the unzipped .MAT file later on.</p>\n<p>I am using MS Access. Any tips?</p>\n<p>Thanks</p>",
  "messages": [
    {
      "id": "52481",
      "postDate": "08/26/2014 22:42:11",
      "content": "<p>Hi guys,</p>\n<p>I downloaded one .gz file and I extract it.&nbsp;</p>\n<p>Zip is asking me to name the extension.&nbsp;</p>\n<p>I am using .MAT but I cannot open the unzipped .MAT file later on.</p>\n<p>I am using MS Access. Any tips?</p>\n<p>Thanks</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "52484",
      "postDate": "08/27/2014 00:01:53",
      "content": "<p>I found the solution in Google as always and NOT in the Kaggle site where it should be.</p>\n<p>&quot;Extraction of the XXX.gz file using WinRAR program gave me a huge no-extension file. After renaming the XXX.gz file as XXX.tar.gz, the extraction gave me several .mat files. I hope this &quot;trick&quot; helps you.&quot;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "52503",
      "postDate": "08/27/2014 12:16:48",
      "content": "<p>Why would you use zip on a gz file? &nbsp;use gunzip or gzip -d</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53039",
      "postDate": "09/03/2014 15:37:11",
      "content": "<p>The files should really be named &quot;Dog_1.tar.gz&quot; etc as they are tarballs (type &quot;file Dog_1.gz&quot; to confirm). &nbsp;Do the following (the mv isn't necessary, but it helps to see what type of file it is from the name).</p>\n<p>&nbsp;&nbsp;mv Dog_1.gz Dog_1.tar.gz</p>\n<p>&nbsp;&nbsp;tar -xvzf Dog_1.tar.gz</p>\n<p>and you'll get files like</p>\n<p>Dog_1/Dog_1_interictal_segment_0033.mat<br>Dog_1/Dog_1_test_segment_0259.mat<br>Dog_1/Dog_1_test_segment_0292.mat<br>Dog_1/Dog_1_interictal_segment_0437.mat</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53041",
      "postDate": "09/03/2014 15:39:35",
      "content": "<p>Hi,</p>\n<p>Yes this is what I did and it worked.</p>\n<p>Still cannot open the MAT files though since I do not have MATLAB. &nbsp;</p>\n<p>Hence, I resigned from this competition :)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53043",
      "postDate": "09/03/2014 15:55:41",
      "content": "<p>Use python's scipy.io (&quot;pip install scipy&quot; should do it):</p>\n\n<p>http://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html#scipy.io.loadmat</p>\n\n<p>import scipy.io as sio</p>\n<p>mat=sio.loadmat('../epilepsy_data/Dog_1/Dog_1_preictal_segment_0002.mat')</p>\n\n<p>mat.keys()<br>Out[5]: ['preictal_segment_2', '__version__', '__header__', '__globals__']</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53052",
      "postDate": "09/03/2014 17:07:17",
      "content": "<p>Thanks for that.</p>\n<p>I am using Spyder (Python 3.3) and I wrote:</p>\n<p>import scipy.io as sio</p>\n<p>mat=sio.loadmat('C:\\Users\\...\\Seizure prediction\\Dog_5\\Dog_5_interictal_segment_0003.mat')</p>\n<p>mat.keys()</p>\n<p>What I get is:&nbsp;</p>\n<p>SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53053",
      "postDate": "09/03/2014 17:13:43",
      "content": "<p>position 2-3 of &quot;c:\\U&quot; is in your string. &nbsp;Try putting the .mat file in your current directory and opening it.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53072",
      "postDate": "09/03/2014 20:46:16",
      "content": "<p>You can use 'gnu octave' its free and does almost the same as matlab</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53701",
      "postDate": "09/14/2014 15:50:34",
      "content": "<p>You can use R to open a .mat file. &nbsp;You first have to download R, which is an open source program for data analysis and visualization. &nbsp;You then have to install the R.matlab package, also free, which allows you to read and write .mat files. &nbsp;Below is the website for the R homepage. &nbsp;Hope this helps.</p>\n<p>http://www.r-project.org/</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53804",
      "postDate": "09/15/2014 15:38:43",
      "content": "<p>The problem with the &quot;c:\\U&quot; is the &quot;\\&quot; character.</p>\n\n<p>Some systems/languages to represent complex characters use combinations of &quot;\\&quot; and another letter. For example &quot;\\t&quot; is tab and &quot;\\n&quot; means &quot;new line&quot;</p>\n\n<p>Try using the character &quot;/&quot; instead of &quot;\\&quot; or alternatively use the complex representation for &quot;\\&quot; which is &quot;\\\\&quot;.</p>\n<p>Summing it up. Try one of the following:</p>\n<p>&quot;C:/Users/...&quot;</p>\n<p>&quot;C:\\\\Users\\\\...&quot;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57145",
      "postDate": "11/01/2014 00:48:19",
      "content": "<p>Hello Omid</p>\n<p>I have downloaded and opened the file in R as you suggested. However I cannot seem to access the variable. as it is too large.</p>\n<p>How did you manipulate the data (say for dog_1 the smallest) after you downloaded the data in R?</p>\n<p>I admit I usually work on the theory side of this and now I am trying to perform more hands on.</p>\n\n<p>Thanks</p>\n\n<p>v/r</p>\n\n<p>-Ray</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57146",
      "postDate": "11/01/2014 01:06:56",
      "content": "<p>Apologies this was already solved.</p>\n<p>Thanks</p>\n<p>v/r</p>\n<p>-Ray</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "58102",
      "postDate": "11/15/2014 07:15:17",
      "content": "<p>I am new to matlab format. Anybody can give me some hint how to go from mat['preictal_segment_2'] to data/data_length_sec/sampling_frequency/channels/sequence ?&nbsp;</p>\n<p>I found&nbsp;mat['preictal_segment_2'] is 1*1 numpy.ndarray, but when i go to&nbsp;mat['preictal_segment_2'][0][0], I got a numpy.void element.</p>\n\n\n\n<p>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</p>\n<p>&gt;&gt;Use python's scipy.io (&quot;pip install scipy&quot; should do it):</p>\n<p>&gt;&gt; http://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html#scipy.io.loadmat</p>\n<p>&gt;&gt; import scipy.io as sio</p>\n<p>&gt;&gt; mat=sio.loadmat('../epilepsy_data/Dog_1/Dog_1_preictal_segment_0002.mat')</p>\n<p>&gt;&gt; mat.keys()<br>&gt;&gt; Out[5]: ['preictal_segment_2', '__version__', '__header__', '__globals__']</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "58103",
      "postDate": "11/15/2014 07:46:01",
      "content": "<p>no need to reply. I found the answer myself --&nbsp;</p>\n\n<p>mat['preictal_segment_2'][0][0] can be further traced down to four elements&nbsp;mat['preictal_segment_2'][0][0][0] ~mat['preictal_segment_2'][0][0][3]</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 52484,
      "author_name": "kchlou",
      "author_url": "",
      "post_date": "08/27/2014 00:01:53",
      "content": "<p>I found the solution in Google as always and NOT in the Kaggle site where it should be.</p>\n<p>&quot;Extraction of the XXX.gz file using WinRAR program gave me a huge no-extension file. After renaming the XXX.gz file as XXX.tar.gz, the extraction gave me several .mat files. I hope this &quot;trick&quot; helps you.&quot;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 52503,
      "author_name": "galexander",
      "author_url": "",
      "post_date": "08/27/2014 12:16:48",
      "content": "<p>Why would you use zip on a gz file? &nbsp;use gunzip or gzip -d</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53039,
      "author_name": "cwilkes",
      "author_url": "",
      "post_date": "09/03/2014 15:37:11",
      "content": "<p>The files should really be named &quot;Dog_1.tar.gz&quot; etc as they are tarballs (type &quot;file Dog_1.gz&quot; to confirm). &nbsp;Do the following (the mv isn't necessary, but it helps to see what type of file it is from the name).</p>\n<p>&nbsp;&nbsp;mv Dog_1.gz Dog_1.tar.gz</p>\n<p>&nbsp;&nbsp;tar -xvzf Dog_1.tar.gz</p>\n<p>and you'll get files like</p>\n<p>Dog_1/Dog_1_interictal_segment_0033.mat<br>Dog_1/Dog_1_test_segment_0259.mat<br>Dog_1/Dog_1_test_segment_0292.mat<br>Dog_1/Dog_1_interictal_segment_0437.mat</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53041,
      "author_name": "kchlou",
      "author_url": "",
      "post_date": "09/03/2014 15:39:35",
      "content": "<p>Hi,</p>\n<p>Yes this is what I did and it worked.</p>\n<p>Still cannot open the MAT files though since I do not have MATLAB. &nbsp;</p>\n<p>Hence, I resigned from this competition :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53043,
      "author_name": "cwilkes",
      "author_url": "",
      "post_date": "09/03/2014 15:55:41",
      "content": "<p>Use python's scipy.io (&quot;pip install scipy&quot; should do it):</p>\n\n<p>http://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html#scipy.io.loadmat</p>\n\n<p>import scipy.io as sio</p>\n<p>mat=sio.loadmat('../epilepsy_data/Dog_1/Dog_1_preictal_segment_0002.mat')</p>\n\n<p>mat.keys()<br>Out[5]: ['preictal_segment_2', '__version__', '__header__', '__globals__']</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53052,
      "author_name": "kchlou",
      "author_url": "",
      "post_date": "09/03/2014 17:07:17",
      "content": "<p>Thanks for that.</p>\n<p>I am using Spyder (Python 3.3) and I wrote:</p>\n<p>import scipy.io as sio</p>\n<p>mat=sio.loadmat('C:\\Users\\...\\Seizure prediction\\Dog_5\\Dog_5_interictal_segment_0003.mat')</p>\n<p>mat.keys()</p>\n<p>What I get is:&nbsp;</p>\n<p>SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53053,
      "author_name": "cwilkes",
      "author_url": "",
      "post_date": "09/03/2014 17:13:43",
      "content": "<p>position 2-3 of &quot;c:\\U&quot; is in your string. &nbsp;Try putting the .mat file in your current directory and opening it.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53072,
      "author_name": "ruiprodrigues",
      "author_url": "",
      "post_date": "09/03/2014 20:46:16",
      "content": "<p>You can use 'gnu octave' its free and does almost the same as matlab</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53701,
      "author_name": "omidrnasserbigdeli",
      "author_url": "",
      "post_date": "09/14/2014 15:50:34",
      "content": "<p>You can use R to open a .mat file. &nbsp;You first have to download R, which is an open source program for data analysis and visualization. &nbsp;You then have to install the R.matlab package, also free, which allows you to read and write .mat files. &nbsp;Below is the website for the R homepage. &nbsp;Hope this helps.</p>\n<p>http://www.r-project.org/</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53804,
      "author_name": "jmarinero",
      "author_url": "",
      "post_date": "09/15/2014 15:38:43",
      "content": "<p>The problem with the &quot;c:\\U&quot; is the &quot;\\&quot; character.</p>\n\n<p>Some systems/languages to represent complex characters use combinations of &quot;\\&quot; and another letter. For example &quot;\\t&quot; is tab and &quot;\\n&quot; means &quot;new line&quot;</p>\n\n<p>Try using the character &quot;/&quot; instead of &quot;\\&quot; or alternatively use the complex representation for &quot;\\&quot; which is &quot;\\\\&quot;.</p>\n<p>Summing it up. Try one of the following:</p>\n<p>&quot;C:/Users/...&quot;</p>\n<p>&quot;C:\\\\Users\\\\...&quot;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57145,
      "author_name": "stormer1120",
      "author_url": "",
      "post_date": "11/01/2014 00:48:19",
      "content": "<p>Hello Omid</p>\n<p>I have downloaded and opened the file in R as you suggested. However I cannot seem to access the variable. as it is too large.</p>\n<p>How did you manipulate the data (say for dog_1 the smallest) after you downloaded the data in R?</p>\n<p>I admit I usually work on the theory side of this and now I am trying to perform more hands on.</p>\n\n<p>Thanks</p>\n\n<p>v/r</p>\n\n<p>-Ray</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57146,
      "author_name": "stormer1120",
      "author_url": "",
      "post_date": "11/01/2014 01:06:56",
      "content": "<p>Apologies this was already solved.</p>\n<p>Thanks</p>\n<p>v/r</p>\n<p>-Ray</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 58102,
      "author_name": "orchid",
      "author_url": "",
      "post_date": "11/15/2014 07:15:17",
      "content": "<p>I am new to matlab format. Anybody can give me some hint how to go from mat['preictal_segment_2'] to data/data_length_sec/sampling_frequency/channels/sequence ?&nbsp;</p>\n<p>I found&nbsp;mat['preictal_segment_2'] is 1*1 numpy.ndarray, but when i go to&nbsp;mat['preictal_segment_2'][0][0], I got a numpy.void element.</p>\n\n\n\n<p>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</p>\n<p>&gt;&gt;Use python's scipy.io (&quot;pip install scipy&quot; should do it):</p>\n<p>&gt;&gt; http://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html#scipy.io.loadmat</p>\n<p>&gt;&gt; import scipy.io as sio</p>\n<p>&gt;&gt; mat=sio.loadmat('../epilepsy_data/Dog_1/Dog_1_preictal_segment_0002.mat')</p>\n<p>&gt;&gt; mat.keys()<br>&gt;&gt; Out[5]: ['preictal_segment_2', '__version__', '__header__', '__globals__']</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 58103,
      "author_name": "orchid",
      "author_url": "",
      "post_date": "11/15/2014 07:46:01",
      "content": "<p>no need to reply. I found the answer myself --&nbsp;</p>\n\n<p>mat['preictal_segment_2'][0][0] can be further traced down to four elements&nbsp;mat['preictal_segment_2'][0][0][0] ~mat['preictal_segment_2'][0][0][3]</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "52481": "",
    "52484": "",
    "52503": "",
    "53039": "",
    "53041": "",
    "53043": "",
    "53052": "",
    "53053": "",
    "53072": "",
    "53701": "",
    "53804": "",
    "57145": "",
    "57146": "",
    "58102": "",
    "58103": ""
  },
  "source": "meta"
}