Repository: catalystneuro/neuroconv

Issue:
[Bug]: BaseImagingExtractorInterface.add_to_nwbfile() requires metadata
### What happened?

The call signature of BaseImagingExtractorInterface.add_to_nwbfile() states that metadata is optional, however if it is ommitted, you get errors because internal functions in fact require it. I am adjusting to use defaults of metadata is missing on internal functions.

### Steps to Reproduce

```python
from pynwb.testing.mock.file import mock_NWBFile
from neuroconv.tools.testing.mock_interfaces import MockImagingInterface

nwbfile = mock_NWBFile()

interface = MockImagingInterface()
interface.add_to_nwbfile(nwbfile)
```


### Traceback

```python
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 4
      1 nwbfile = mock_NWBFile()
      3 interface = MockImagingInterface()
----> 4 interface.add_to_nwbfile(nwbfile)

File ~/dev/neuroconv/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py:132, in BaseImagingExtractorInterface.add_to_nwbfile(self, nwbfile, metadata, photon_series_type, photon_series_index, parent_container, stub_test, stub_frames)
    129 else:
    130     imaging_extractor = self.imaging_extractor
--> 132 add_imaging(
    133     imaging=imaging_extractor,
    134     nwbfile=nwbfile,
    135     metadata=metadata,
    136     photon_series_type=photon_series_type,
    137     photon_series_index=photon_series_index,
    138     parent_container=parent_container,
    139 )

File ~/dev/neuroconv/src/neuroconv/tools/roiextractors/roiextractors.py:559, in add_imaging(imaging, nwbfile, metadata, photon_series_type, photon_series_index, iterator_type, iterator_options, parent_container)
    549 def add_imaging(
    550     imaging: ImagingExtractor,
    551     nwbfile: NWBFile,
   (...)
    557     parent_container: Literal["acquisition", "processing/ophys"] = "acquisition",
    558 ):
--> 559     add_devices(nwbfile=nwbfile, metadata=metadata)
    560     add_photon_series(
    561         imaging=imaging,
    562         nwbfile=nwbfile,
   (...)
    568         parent_container=parent_container,
    569     )

File ~/dev/neuroconv/src/neuroconv/tools/roiextractors/roiextractors.py:201, in add_devices(nwbfile, metadata)
    199 metadata_copy = deepcopy(metadata)
    200 default_metadata = get_default_ophys_metadata()
--> 201 metadata_copy = dict_deep_update(default_metadata, metadata_copy, append_list=False)
    202 device_metadata = metadata_copy["Ophys"]["Device"]
    204 for device in device_metadata:

File ~/dev/neuroconv/src/neuroconv/utils/dict.py:187, in dict_deep_update(d, u, append_list, remove_repeats, copy, compare_key, list_dict_deep_update)
    184 if copy:
    185     dict_to_update = deepcopy(dict_to_update)
--> 187 for key_to_update, update_values in dict_with_update_values.items():
    188     # Update with a dict like object is recursive until an empty dict is found.
    189     if isinstance(update_values, collections.abc.Mapping):
    190         sub_dict_to_update = dict_to_update.get(key_to_update, dict())

AttributeError: 'NoneType' object has no attribute 'items'
```


### Operating System

macOS

### Python Executable

Conda

### Python Version

3.9

### Package Versions

_No response_

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/catalystneuro/neuroconv/blob/main/.github/CODE_OF_CONDUCT.rst)
- [X] Have you ensured this bug was not already [reported](https://github.com/catalystneuro/neuroconv/issues)?

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.67%. Comparing base [(`ff081fc`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/ff081fc6e3befc5948e2ed4f97500e166e0a76f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`e027723`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         122      122           
  Lines        6761     6761           
=======================================
  Hits         6198     6198           
  Misses        563      563           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.67% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.67%. Comparing base [(`ff081fc`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/ff081fc6e3befc5948e2ed4f97500e166e0a76f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`e027723`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

> :exclamation: Current head e027723 differs from pull request most recent head 0914429. Consider uploading reports for the commit 0914429 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         122      122           
  Lines        6761     6761           
=======================================
  Hits         6198     6198           
  Misses        563      563           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.67% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.67%. Comparing base [(`ff081fc`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/ff081fc6e3befc5948e2ed4f97500e166e0a76f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`e027723`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

> :exclamation: Current head e027723 differs from pull request most recent head 0914429. Consider uploading reports for the commit 0914429 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         122      122           
  Lines        6761     6761           
=======================================
  Hits         6198     6198           
  Misses        563      563           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.67% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.67%. Comparing base [(`ff081fc`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/ff081fc6e3befc5948e2ed4f97500e166e0a76f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`e027723`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

> :exclamation: Current head e027723 differs from pull request most recent head 8850327. Consider uploading reports for the commit 8850327 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         122      122           
  Lines        6761     6761           
=======================================
  Hits         6198     6198           
  Misses        563      563           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.67% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.67%. Comparing base [(`ff081fc`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/ff081fc6e3befc5948e2ed4f97500e166e0a76f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`e027723`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

> :exclamation: Current head e027723 differs from pull request most recent head 74283b9. Consider uploading reports for the commit 74283b9 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         122      122           
  Lines        6761     6761           
=======================================
  Hits         6198     6198           
  Misses        563      563           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.67% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.62%. Comparing base [(`9f92b45`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/9f92b457c7ae26db2f6d42d9af0cf680049322ec?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`74283b9`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.62%   91.62%           
=======================================
  Files         123      123           
  Lines        6771     6771           
=======================================
  Hits         6204     6204           
  Misses        567      567           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.62% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.62%. Comparing base [(`9f92b45`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/9f92b457c7ae26db2f6d42d9af0cf680049322ec?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`74283b9`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

> :exclamation: Current head 74283b9 differs from pull request most recent head c286043. Consider uploading reports for the commit c286043 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.62%   91.62%           
=======================================
  Files         123      123           
  Lines        6771     6771           
=======================================
  Hits         6204     6204           
  Misses        567      567           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.62% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.62%. Comparing base [(`9f92b45`)](https://app.codecov.io/gh/catalystneuro/neuroconv/commit/9f92b457c7ae26db2f6d42d9af0cf680049322ec?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) to head [(`c286043`)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro).
> Report is 1 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/graphs/tree.svg?width=650&height=150&src=pr&token=h63OQoWehP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro)

```diff
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   91.62%   91.62%           
=======================================
  Files         123      123           
  Lines        6771     6771           
=======================================
  Hits         6204     6204           
  Misses        567      567           
```

| [Flag](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | `91.62% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro) | Coverage Δ | |
|---|---|---|
| [src/neuroconv/tools/roiextractors/roiextractors.py](https://app.codecov.io/gh/catalystneuro/neuroconv/pull/849?src=pr&el=tree&filepath=src%2Fneuroconv%2Ftools%2Froiextractors%2Froiextractors.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalystneuro#diff-c3JjL25ldXJvY29udi90b29scy9yb2lleHRyYWN0b3JzL3JvaWV4dHJhY3RvcnMucHk=) | `88.02% <100.00%> (ø)` | |

</details>

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 902e1652..c543012c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
 * Fixed an issue with `set_aligned_starting_time` for all `SortingInterface`'s that did not have an initial segment start set (and no recording attached). [PR #823](https://github.com/catalystneuro/neuroconv/pull/823)
 * Fixed a bug with `parameterized` and `pytest-xdist==3.6.1` in the `ScanImageImagingInterface` tests: [PR #829](https://github.com/catalystneuro/neuroconv/pull/829)
 * Added `XX` and `XO` to the base metadata schema. [PR #833](https://github.com/catalystneuro/neuroconv/pull/833)
+* `BaseImagingExtractor.add_to_nwbfile()` is fixed in the case where metadata is not supplied [PR #849](https://github.com/catalystneuro/neuroconv/pull/849)
 
 ### Features
 * Added `backend` control to the `make_or_load_nwbfile` helper method in `neuroconv.tools.nwb_helpers`. [PR #800](https://github.com/catalystneuro/neuroconv/pull/800)
diff --git a/src/neuroconv/tools/roiextractors/roiextractors.py b/src/neuroconv/tools/roiextractors/roiextractors.py
index 7fb85acf..87e36dba 100644
--- a/src/neuroconv/tools/roiextractors/roiextractors.py
+++ b/src/neuroconv/tools/roiextractors/roiextractors.py
@@ -189,14 +189,14 @@ def get_nwb_imaging_metadata(
     return metadata
 
 
-def add_devices(nwbfile: NWBFile, metadata: dict) -> NWBFile:
+def add_devices(nwbfile: NWBFile, metadata: Optional[dict] = None) -> NWBFile:
     """
     Add optical physiology devices from metadata.
     The metadata concerning the optical physiology should be stored in metadata["Ophys]["Device"]
     This function handles both a text specification of the device to be built and an actual pynwb.Device object.
 
     """
-    metadata_copy = deepcopy(metadata)
+    metadata_copy = {} if metadata is None else deepcopy(metadata)
     default_metadata = get_default_ophys_metadata()
     metadata_copy = dict_deep_update(default_metadata, metadata_copy, append_list=False)
     device_metadata = metadata_copy["Ophys"]["Device"]
@@ -342,7 +342,7 @@ def add_image_segmentation(nwbfile: NWBFile, metadata: dict) -> NWBFile:
 def add_photon_series(
     imaging: ImagingExtractor,
     nwbfile: NWBFile,
-    metadata: dict,
+    metadata: Optional[dict] = None,
     photon_series_type: Literal["TwoPhotonSeries", "OnePhotonSeries"] = "TwoPhotonSeries",
     photon_series_index: int = 0,
     parent_container: Literal["acquisition", "processing/ophys"] = "acquisition",
@@ -391,7 +391,7 @@ def add_photon_series(
 
     iterator_options = iterator_options or dict()
 
-    metadata_copy = deepcopy(metadata)
+    metadata_copy = {} if metadata is None else deepcopy(metadata)
     assert photon_series_type in [
         "OnePhotonSeries",
         "TwoPhotonSeries",


Test patch:
diff --git a/tests/test_ophys/test_ophys_interfaces.py b/tests/test_ophys/test_ophys_interfaces.py
index 85b1ab41..7c6685f7 100644
--- a/tests/test_ophys/test_ophys_interfaces.py
+++ b/tests/test_ophys/test_ophys_interfaces.py
@@ -1,5 +1,7 @@
 import unittest
 
+from pynwb.testing.mock.file import mock_NWBFile
+
 from neuroconv.tools.testing.mock_interfaces import MockImagingInterface
 
 
@@ -9,3 +11,7 @@ class TestMockImagingInterface(unittest.TestCase):
 
     def test_run_conversion(self):
         self.mock_imaging_interface.run_conversion()
+
+    def test_add_to_nwbfile(self):
+        nwbfile = mock_NWBFile()
+        self.mock_imaging_interface.add_to_nwbfile(nwbfile)
diff --git a/tests/test_ophys/test_tools_roiextractors.py b/tests/test_ophys/test_tools_roiextractors.py
index 3b208655..06673c1c 100644
--- a/tests/test_ophys/test_tools_roiextractors.py
+++ b/tests/test_ophys/test_tools_roiextractors.py
@@ -11,7 +11,6 @@ from unittest.mock import Mock
 
 import numpy as np
 import psutil
-import pynwb.testing.mock.file
 import pytest
 from hdmf.data_utils import DataChunkIterator
 from hdmf.testing import TestCase
@@ -43,6 +42,7 @@ from neuroconv.tools.roiextractors.imagingextractordatachunkiterator import (
 from neuroconv.tools.roiextractors.roiextractors import (
     get_default_segmentation_metadata,
 )
+from neuroconv.tools.testing.mock_interfaces import MockImagingInterface
 from neuroconv.utils import dict_deep_update