Correct use of the space entity

I am trying to get my head around the specification regarding images coregistered to a different image in native space. Say, for example, I coregistered a FLAIR to a T1w, and then used both to generate a map of white matter hyperintensities, how should I denote the space? Here’s my current understanding, please correct me if I’m wrong:
rawdata: does not include a ‘space’ entity, nor a SpatialReference metadata object in the JSON sidecar.
derivatives/preprocessed/T1w: since it is in the same space, either it has no label, or it has the entity ‘space-orig’ without a SpatialReference object.
derivatives/preprocessed/FLAIR: ‘space-individual’ in filename, “SpatialReference”: “<relative/path/to/T1w>” in JSON sidecar.
derivatives/WMH/WMHmask: either ‘space-orig’ like T1w, or ‘space-individual’ like FLAIR (since it was derived from both), either way, include SpatialReference to T1w in sidecar.
Thank you for helping me figure this out. It would be nice to have an example in the docs, as currently there only one seems to use a standard space, not a subject-specific (or group-specific) space.
Paul

Correct.

Yes, if there is no external reference, then there’s nothing to put.

Yes.

This seems correct as well. Additionally, the RawSources is REQUIRED for masks, which should point to the path of the raw input files, relative to the raw dataset root.

Thanks. On the last point, can you clarify: should the mask use space-orig or space-individual? Also, if I’m using the structure:
study/
study/rawdata/sub etc.
study/derived/sub etc.
I think the specification says the RawSources are relative to the study root directory. Is that correct?

I think either would work fine, as far as BIDS is concerned.

No. BIDS has no concept of the relative locations of datasets, so all relative paths are relative to a BIDS dataset root. For the raw dataset, the root is study/rawdata.

Can you clarify the definition of ‘dataset’? In my example (adding the pipeline level):
./study/
./study/rawdata/sub-001 etc.
./study/derived/preproc/sub-001 etc.
./study/derived/lesionIdentification/sub-001 etc.

My initial understanding was that the dataset root is ‘./study’, but it sounds like the raw data and each of the pipeline locations are each datasets as far as the JSONs within are concerned. Is that correct? In this case, if a file in ‘preproc’ was a source for a file in ‘lesionIdentification’, would I put in the JSON something like this?
‘…/preproc/sub-001/thisfile.nii’
Then for raw, do I need this?
‘…/…/rawdata/sub-001/thisfile.nii’