# Troubleshooting Missing Imaging Data

### Why is my data missing??

Sometimes you go to download data from a subject, and it's not there. I don't mean the series are missing from the NiDB website, but the data is actually missing from the disk.

This can happen for a lot of reasons, usually because studies are moved from one subject to another before they are completely archived. Also for the following reasons

* Subjects are merged, but data is not completely copied over on disk
* Subject ID is incorrectly entered on the MR scanner console. This causes a new ID to be generated. If the study is later moved to the correct ID, some data might not be moved over on disk
* A subject is deleted. But since data is never really deleted from NiDB, it's possible that a study was moved to that subject and not all data on disk is copied over

### Example

Suppose we have subject S1234ABC. This subject has one study, and ten series in that study. We'd expect to see the following on the website for subject S1234BC study 2.

```
S1234ABC/2

1  Localizer
2  T1w
3  T2w
4  Fieldmap
5  SE_AP
6  SE_PA
7  Task 1
8  Task 2
9  Task 3
10 Task 4
```

But, we go to export the data through the search page or through a pipeline, and not all of the series have data! If we look on the disk, we see there are series missing.

```
> cd /nidb/data/archive/S1234ABC/2
> ls
1
2
3
4
5
>
```

That's not good. This could also appear as though all series directories do exist, but if we dig deeper, we find that the `dicom` directory for each series is missing or empty. So, where's the data? We have to do some detective work.

Let's look around the subject's directory on the disk.

```
> cd /nidb/data/archive/S1234ABC
> ls
1
2
```

That's interesting, there appears to be another directory. Our study is 2, but there's also a study 1, and it doesn't show up on the NiDB website. Maybe our data is in there? Let's look.

```
> cd /nidb/data/archive/S1234ABC/1
> ls
1
2
3
4
5
6
7
8
9
10
```

That looks like our data! We can verify by doing a diff between directories that exist in both studies.

```
> cd /nidb/data/archive/S1234ABC
> diff 1/1/dicom 2/1/dicom
>
```

If this is the data we are looking for, we can copy all of the data from study 1 to study 2.

```
> cd /nidb/data/archive/S1234ABC
> cp -ruv 1/* 2/
```

After the copying is done, you should be able to go back to the study page, and click the **View file list** button at the bottom and see all of expected series.


---

# 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.neuroinfodb.org/nidb/tutorials/working-with-imaging-data/troubleshooting-missing-imaging-data.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.
