# Syncing your XNAT project & Oscar data directory

This feature automates the export process by analyzing the existing projects in your data directory along with their associated subjects and sessions, and then identifies and fetches missing sessions that exist remotely on XNAT. The script will check the insertion date and time for every session in your XNAT project. If you have data on XNAT that is newer than the sessions in your project directory on Oscar, we can assume that the XNAT data needs to be pulled over to Oscar.

## Diff: Identify data on XNAT that is not yet on Oscar

To get a report of any project data on XNAT that is not present in your data directory, use the `--diff` flag alongside the path to the root of your BIDS directory. This option will only produce a report, not perform the sync.

If you are passing in a configuration file where bids\_root is defined, or if your data directory is `~/bids-export`, there is no need to pass `<BIDS_ROOT>` as an argument alongside `--diff.`

```bash
python /oscar/data/bnc/scripts/run_xnat2bids.py --diff <BIDS_ROOT> 
```

## Sync: export new XNAT data to a project on Oscar

To sync your data directory, use `--update` alongside the path to the root of your BIDS directory.

If you are passing in a configuration file where bids\_root is defined, or if your data directory is `~/bids-export`, there is no need to pass `<BIDS_ROOT>` as an argument alongside `--update.`

```bash
python /oscar/data/bnc/scripts/run_xnat2bids.py --update <BIDS_ROOT> 
```

***

**NOTE:** If you manually add resources or scan data to your project, XNAT will not automatically update the insertion date/time, so it will not be identified as new data that needs to be synced. If you would like to use the "sync" functionality on manually added data, you will need to update the date field in XNAT for the given session that you want to sync.

To do this:

1. Open XNAT and navigate to the session page you would like to sync
2. Select Edit from the Actions panel

<figure><img src="https://4276957606-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtSg7ZEM6EHbi9iE84a%2Fuploads%2FGtEqk1RThjyHVZJHzk2b%2FScreenshot%202026-03-24%20at%2011.07.14%E2%80%AFAM.png?alt=media&#x26;token=67bd2df9-63fd-4dd1-92ac-e3ecfeb08dbe" alt="A view of the Edit button, underneath &#x22;Actions&#x22; on the right hand side of a session on XNAT."><figcaption></figcaption></figure>

3\. Update the "Date" field to the current date, or the date of manual change.

<figure><img src="https://4276957606-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtSg7ZEM6EHbi9iE84a%2Fuploads%2Frtm6MWonoFSqo6KKxpz1%2FScreenshot%202026-03-24%20at%2011.12.21%E2%80%AFAM.png?alt=media&#x26;token=c57699b1-7a29-4054-9e95-5b5adfd3e97a" alt="After pressing the &#x22;edit option&#x22;, you will be able to edit the Date of a scan session on XNAT."><figcaption></figcaption></figure>

4\. Select "Submit" at the bottom of the page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ccv.brown.edu/bnc-user-manual/xnat-to-bids-intro/using-oscar/oscar-utility-script/syncing-your-xnat-project-and-oscar-data-directory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
