# Units for compute\_current\_source\_density

**URL:** <https://mne.discourse.group/t/units-for-compute-current-source-density/9297>\
**Category:** Support & Discussions\
**Tags:** csd\
**Created:** [September 9, 2024, 7:43am UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297 "2024-09-09T07:43:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/johan/32/3763_2.png) [@Johan](https://mne.discourse.group/u/Johan)\
**Post date:** [September 9, 2024, 7:43am UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/1 "2024-09-09T07:43:38Z")

</div>

Hi everyone,

I’m confused about the units in `compute_current_source_density()`. What unit does the function return as output, if we have Volts as input?

In my code below, if I enter µV in the function, what does it return? `V/m²` or `µV/m²`?  
Then, when I want to retrieve my data with `get_data()`, is it necessary to specify the units?

Because all MNE should be in SI units, I suppose we have to work with Volt, and convert it later to µV? I only found [this](https://mne.discourse.group/t/units-before-and-after-compute-current-source-density/8897/2) and [this subject](https://mne.discourse.group/t/mne-preprocessing-compute-current-source-density-returns-strange-units/5889) in forum.

In fact, my question is which unit comes out of `compute_current_source_density()` according to its input, and how do I get them back as an array with the right unity?

Here’s my code:

```python
### Compute CSD
# Convert array data to epochs mne
epochs_MNE = mne.EpochsArray(epochs_array[:,:64, :] * 1e6, info_temp) # I multiply epochs (in V) to obtain µV

# CSD calculation (input is µV so I supposed output is µVm²)
epochs_MNE_CSD = mne.preprocessing.compute_current_source_density(epochs_MNE)

# Convert to array and select units
epochs_MNE_CSD.copy().get_data(units='µV/m²') 

```

Thanks to all !

Johan

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [September 9, 2024, 8:28am UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/2 "2024-09-09T08:28:43Z")

</div>

Why not work in SI units in which case the unit will be `V/m²` as suggested here [Units before and after compute\_current\_source\_density - #4 by larsoner](https://mne.discourse.group/t/units-before-and-after-compute-current-source-density/8897/4) ?

```python
epochs_MNE = mne.EpochsArray(epochs_array[:,:64, :], info_temp) # don't convert to µV
# CSD calculation (input is V so output is V/m²)
epochs_MNE_CSD = mne.preprocessing.compute_current_source_density(epochs_MNE)
epochs_MNE_CSD.get_data()

```

Mathieu

---

<div class="post-metadata">

**Author:** ![Johan](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/johan/32/3763_2.png) [@Johan](https://mne.discourse.group/u/Johan)\
**Post date:** [September 9, 2024, 8:45am UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/3 "2024-09-09T08:45:10Z")

</div>

@mscheltienne Thanks for the answer.  
Yes indeed you’re right, I also did it that way for safety.

In this case, with `Volts` at the input, I’m sure I’ll get `V/m²` at the output and I won’t make any unit errors?

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [September 11, 2024, 2:12pm UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/4 "2024-09-11T14:12:20Z")

</div>

@Johan yes that should be correct unless we have some bug – we try to stick to SI units for data storage and retrieval

---

<div class="post-metadata">

**Author:** ![Johan](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/johan/32/3763_2.png) [@Johan](https://mne.discourse.group/u/Johan)\
**Post date:** [September 11, 2024, 2:33pm UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/5 "2024-09-11T14:33:30Z")

</div>

@larsoner Thank you very much !

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [September 18, 2024, 2:33pm UTC](https://mne.discourse.group/t/units-for-compute-current-source-density/9297/6 "2024-09-18T14:33:45Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
