title: "IsADirectoryError: [Errno 21] Is a directory: " It is a file
body: <p>I already split the data into test and training set into the different folder. Now I need to load the patient data. Each patient has 8 images.</p>
  <pre class="lang-py prettyprint-override"><code>def load_dataset(root_dir, split):
      &quot;&quot;&quot;
      load the data set numpy arrays saved by the preprocessing script
      :param root_dir: path to input data
      :param split: defines whether to load the training or test set
      :return: data: dictionary containing one dictionary ({'data', 'seg', 'pid'}) per patient
      &quot;&quot;&quot;
      in_dir = os.path.join(root_dir, split)
      data_paths = [os.path.join(in_dir, f) for f in os.listdir(in_dir)]
      data_and_seg_arr = [np.load(ii, mmap_mode='r') for ii in data_paths]
      pids = [ii.split('/')[-1].split('.')[0] for ii in data_paths]
      data = OrderedDict()
      for ix, pid in enumerate(pids):
          data[pid] = {'data': data_and_seg_arr[ix][..., 0], 'seg': data_and_seg_arr[ix][..., 1], 'pid': pid}
      return data
  </code></pre>
  <p>But, the error said:</p>
  <pre><code>File &quot;/home/zhe/Research/Seg/heart_seg/data_loader.py&quot;, line 61, in load_dataset
  data_and_seg_arr = [np.load(ii, mmap_mode='r') for ii in data_paths]
  File &quot;/home/zhe/Research/Seg/heart_seg/data_loader.py&quot;, line 61, in &lt;listcomp&gt;
  data_and_seg_arr = [np.load(ii, mmap_mode='r') for ii in data_paths]
  File &quot;/home/zhe/anaconda3/envs/tf_env/lib/python3.6/site-packages/numpy/lib/npyio.py&quot;, line 372, in load
  fid = open(file, &quot;rb&quot;)
  IsADirectoryError: [Errno 21] Is a directory: './data/preprocessed_data/train/Patient009969'
  </code></pre>
  <p>It is already a file name, not a directory. Thanks!</p>