# Creating a Pipeline

To start working with the system, you first need to import the main libraries and modules.\
If you plan to use **ISX** functions, import the package and pass it as a parameter when creating the `CIPipe` instance.

```
import isx
from ci_pipe.pipeline import CIPipe
```

The `CIPipe` class is responsible for building and executing an **analysis pipeline**.\
There are two main ways to create an instance: automatically from a directory of videos, or manually from a list of input files.\
Both approaches use the same parameters, with several optional ones that will be explained later.

***

#### 1. Automatic creation from a video directory

The most convenient way to initialize a pipeline is by using the class method `with_videos_from_directory`, which automatically generates the input list from a directory containing the videos to be processed.

```
pipeline = CIPipe.with_videos_from_directory(
    'input_dir',
    outputs_directory='output_dir',
    isx=isx
)
```

#### 2. Manual creation from a list of inputs

In more specific cases, the `CIPipe` class can be initialized directly by passing a list of input files or paths instead of a directory.

```
pipeline = CIPipe(pipeline_input, file_system=self._file_system, isx=isx)
```

***

#### Passing Arguments

When creating a `CIPipe` instance, additional arguments can be passed directly through the constructor or the class method. For example, to specify a custom branch name:

```
pipeline = CIPipe.with_videos_from_directory(
    'input_dir',
    outputs_directory='output_dir',
    branch_name='Experiment Branch'
)
```

#### Pipeline Setup Parameters

* **input / pipeline\_input**: path to the directory or list of files that will be used as pipeline inputs.\
  The system will read the videos from this location and apply the defined processing steps.
* **outputs\_directory**: name of the directory where the processing results will be stored.\
  If not specified, a folder named **`output`** will be automatically created in the current working directory.\
  You can specify a different name to organize separate runs or experiments.
* **isx** *(optional)*: the *Inscopix* (ISX) library module.\
  If your pipeline includes steps that use ISX, pass it as a parameter.\
  Otherwise, it can be omitted.
* **branch\_name** *(optional)*: the name of the pipeline branch (default: `"Main Branch"`).\
  This parameter allows defining different branches or versions of the pipeline, which will be explained in a later section.

Additionally, there are other optional parameters (set to `None` by default) that allow customizing aspects such as the filesystem, default values, and validation mechanisms. These will be covered in later sections.


---

# 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://cipipe.gitbook.io/cipipe-docs/creating-a-pipeline/creating-a-pipeline.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.
