You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, anonymize_info() preserves age (instead of the full birthday), which is both anonymized and useful for many analyses (and there is no way to disable this behavior). The same argument seems to apply to sex, but this field is currently dropped (set to 0 for unknown).
In #8130, there appeared to be consensus that keeping sex would be acceptable, but it was never implemented (or exposed via a parameter). Would it make sense to retain sex by default (in line with keeping age), or at least add a parameter to control this? I'm happy to submit a PR.
I just noticed that keep_his=True actually retains not only his_id, but also sex and hand (see https://github.com/mne-tools/mne-python/blob/main/mne/_fiff/meas_info.py#L3721-L3731). This is undocumented behavior, so we definitely need to fix something here. I suggest that keep_his=True only retains his_id, and that we keep sex and hand (just like we keep age). Alternatively, I would add two new parameters keep_sex=False and keep_hand=False, but then we should discuss dropping the age as well in order to have a "fully anonymized" data set in the sense that not even age is kept.
FYI HIS is an acronym, "hospital information system". It is possible that handedness and sex might also (have historically) come from that system, not sure...
But anyhow, the proposal to add keep_sex and keep_hand is okay but then we'd also want keep_his_id instead of keep_his, and it would create code churn for people, need deprecation, etc. To minimize disruption and stay backward compatible, why don't we do keep_his: tuple[Literal["hand", "id", "sex"], ...] | bool where True is an alias for ("hand", "id", "sex"), and False is an alias for (). Old code still works as it did before with bool, new code can be more granular in terms of which bits of information are kept by passing a tuple of desired fields to keep. And as part of this, documenting that True is an alias is an alias of that tuple will make clear what is kept. The disadvantage is a slight misnomer in the keep_his= (which would be slightly nicer as keep=) but to me that little bit of pain is worth not forcing people to modify their code.
Activity
cbrnr commentedon Feb 6, 2026
I just noticed that
keep_his=Trueactually retains not onlyhis_id, but alsosexandhand(see https://github.com/mne-tools/mne-python/blob/main/mne/_fiff/meas_info.py#L3721-L3731). This is undocumented behavior, so we definitely need to fix something here. I suggest thatkeep_his=Trueonly retainshis_id, and that we keepsexandhand(just like we keep age). Alternatively, I would add two new parameterskeep_sex=Falseandkeep_hand=False, but then we should discuss dropping the age as well in order to have a "fully anonymized" data set in the sense that not even age is kept.larsoner commentedon Feb 9, 2026
FYI HIS is an acronym, "hospital information system". It is possible that handedness and sex might also (have historically) come from that system, not sure...
But anyhow, the proposal to add
keep_sexandkeep_handis okay but then we'd also wantkeep_his_idinstead ofkeep_his, and it would create code churn for people, need deprecation, etc. To minimize disruption and stay backward compatible, why don't we dokeep_his: tuple[Literal["hand", "id", "sex"], ...] | boolwhereTrueis an alias for("hand", "id", "sex"), andFalseis an alias for(). Old code still works as it did before withbool, new code can be more granular in terms of which bits of information are kept by passing atupleof desired fields to keep. And as part of this, documenting thatTrueis an alias is an alias of that tuple will make clear what is kept. The disadvantage is a slight misnomer in thekeep_his=(which would be slightly nicer askeep=) but to me that little bit of pain is worth not forcing people to modify their code.cbrnr commentedon Feb 9, 2026
Good idea!