Repository: mne-tools/mne-python

Issue:
Report.parse_folder() does not support Path

#### Describe the bug
`Report.parse_folder()` does doesn't handle `pathlib.Path` input correctly, while other MNE functions do.

#### Steps to reproduce
```python
import pathlib
import mne

p = pathlib.Path('foo')
report = mne.Report()
report.parse_folder(p)
```

#### Expected results
```
Embedding : jquery.js
Embedding : jquery-ui.min.js
Embedding : bootstrap.min.js
Embedding : jquery-ui.min.css
Embedding : bootstrap.min.css
Iterating over 0 potential files (this may take some time)
```

#### Actual results
```python
Embedding : jquery.js
Embedding : jquery-ui.min.js
Embedding : bootstrap.min.js
Embedding : jquery-ui.min.css
Embedding : bootstrap.min.css
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Untitled-1 in 
      5 p = pathlib.Path('foo')
      6 report = mne.Report()
----> 7 report.parse_folder(p)

 in parse_folder(self, data_path, pattern, n_jobs, mri_decim, sort_sections, on_error, image_format, render_bem, verbose)

~/Development/mne-python/mne/report.py in parse_folder(self, data_path, pattern, n_jobs, mri_decim, sort_sections, on_error, image_format, render_bem, verbose)
   1445 
   1446         if self.title is None:
-> 1447             self.title = 'MNE Report for ...%s' % self.data_path[-20:]
   1448 
   1449         if not isinstance(pattern, (list, tuple)):

TypeError: 'PosixPath' object is not subscriptable
```


Discussion:

Resolving patch:
diff --git a/mne/report.py b/mne/report.py
--- a/mne/report.py
+++ b/mne/report.py
@@ -25,7 +25,7 @@
 from .io.pick import _DATA_CH_TYPES_SPLIT
 from .source_space import _mri_orientation
 from .utils import (logger, verbose, get_subjects_dir, warn,
-                    fill_doc, _check_option)
+                    fill_doc, _check_option, _validate_type)
 from .viz import (plot_events, plot_alignment, plot_cov, plot_projs_topomap,
                   plot_compare_evokeds)
 from .viz.misc import _plot_mri_contours, _get_bem_plotting_surfaces
@@ -1436,6 +1436,8 @@ class construction.
             .. versionadded:: 0.16
         %(verbose_meth)s
         """
+        _validate_type(data_path, 'path-like', 'data_path')
+        data_path = str(data_path)
         image_format = _check_image_format(self, image_format)
         _check_option('on_error', on_error, ['ignore', 'warn', 'raise'])
         self._sort = sort_sections


Test patch:
diff --git a/mne/tests/test_report.py b/mne/tests/test_report.py
--- a/mne/tests/test_report.py
+++ b/mne/tests/test_report.py
@@ -9,6 +9,7 @@
 import os
 import os.path as op
 import shutil
+import pathlib
 
 import numpy as np
 from numpy.testing import assert_equal
@@ -153,6 +154,7 @@ def test_render_report(renderer, tmpdir):
     # SVG rendering
     report = Report(info_fname=raw_fname_new, subjects_dir=subjects_dir,
                     image_format='svg')
+    tempdir = pathlib.Path(tempdir)  # test using pathlib.Path
     with pytest.warns(RuntimeWarning, match='Cannot render MRI'):
         report.parse_folder(data_path=tempdir, on_error='raise')