• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

angelolab / tmi / 198

pending completion
198

Pull #18

travis-ci-com

web-flow
Merge b7d4d1006 into 6b5a3665d
Pull Request #18: Loosened Pillow Dependencies

246 of 257 branches covered (95.72%)

Branch coverage included in aggregate %.

430 of 442 relevant lines covered (97.29%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/tmi/data_utils.py
1
import math
1✔
2

3
import numpy as np
1✔
4
import xarray as xr
1✔
5

6

7
def stitch_images(data_xr, num_cols):
1✔
8
    """Stitch together a stack of different channels from different FOVs into a single 2D image
9
    for each channel
10

11
    Args:
12
        data_xr (xarray.DataArray):
13
            xarray containing image data from multiple fovs and channels
14
        num_cols (int):
15
            number of images stitched together horizontally
16

17
    Returns:
18
        xarray.DataArray:
19
            the stitched image data
20
    """
21

22
    num_imgs = data_xr.shape[0]
1✔
23
    num_rows = math.ceil(num_imgs / num_cols)
1✔
24
    row_len = data_xr.shape[1]
1✔
25
    col_len = data_xr.shape[2]
1✔
26

27
    total_row_len = num_rows * row_len
1✔
28
    total_col_len = num_cols * col_len
1✔
29

30
    stitched_data = np.zeros(
1✔
31
        (1, total_row_len, total_col_len, data_xr.shape[3]), dtype=data_xr.dtype
32
    )
33

34
    img_idx = 0
1✔
35
    for row in range(num_rows):
1✔
36
        for col in range(num_cols):
1✔
37
            stitched_data[
1✔
38
                0, row * row_len : (row + 1) * row_len, col * col_len : (col + 1) * col_len, :
39
            ] = data_xr[img_idx, ...]
40
            img_idx += 1
1✔
41
            if img_idx == num_imgs:
1✔
42
                break
1✔
43

44
    stitched_xr = xr.DataArray(
1✔
45
        stitched_data,
46
        coords=[["stitched_image"], range(total_row_len), range(total_col_len), data_xr.channels],
47
        dims=["fovs", "rows", "cols", "channels"],
48
    )
49
    return stitched_xr
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc