Ejemplo n.º 1
0
}

export function getMeshSource(chunkManager: ChunkManager, url: string, lod: number) {
  const [baseUrls, path] = parseSpecialUrl(url);
  return getShardedMeshSource(chunkManager, {baseUrls, path, lod});
}

let existingVolumes = new Map<string, Promise<MultiscaleVolumeChunkSource>>();
export function getShardedVolume(baseUrls: string[], path: string) {
  let fullKey = stableStringify({'baseUrls': baseUrls, 'path': path});
  let existingResult = existingVolumes.get(fullKey);
  if (existingResult !== undefined) {
    return existingResult;
  }
  let promise = sendHttpRequest(openShardedHttpRequest(baseUrls, path + '/info'), 'json')
                    .then(response => new MultiscaleVolumeChunkSource(baseUrls, path, response));
  existingVolumes.set(fullKey, promise);
  return promise;
}

export function getVolume(url: string) {
  const [baseUrls, path] = parseSpecialUrl(url);
  return getShardedVolume(baseUrls, path);
}

registerDataSourceFactory('precomputed', {
  description: 'Precomputed file-backed data source',
  getVolume: getVolume,
  getMeshSource: getMeshSource,
});
Ejemplo n.º 2
0
          mat4.create(), info.qoffset, info.quatern, kOneVec, info.qfac),
      volumeSourceOptions,
    });
    return [[VolumeChunkSource.get(this.chunkManager, spec, {url: this.url})]];
  }

  getMeshSource(): null {
    return null;
  }
}

const VolumeChunkSource = defineParameterizedVolumeChunkSource(VolumeSourceParameters);

function getNiftiVolumeInfo(chunkManager: ChunkManager, url: string, cancellationToken: CancellationToken) {
  return chunkManager.rpc!.promiseInvoke<NiftiVolumeInfo>(
      GET_NIFTI_VOLUME_INFO_RPC_ID, {'chunkManager': chunkManager.addCounterpartRef(), 'url': url},
      cancellationToken);
}

export function getVolume(chunkManager: ChunkManager, url: string) {
  return chunkManager.memoize.getUncounted(
      {type: 'nifti/getVolume', url},
      () => getNiftiVolumeInfo(chunkManager, url, uncancelableToken)
                .then(info => new MultiscaleVolumeChunkSource(chunkManager, url, info)));
}

registerDataSourceFactory('nifti', {
  description: 'Single NIfTI file',
  getVolume: getVolume,
});
Ejemplo n.º 3
0
};

let existingVolumes = new Map<string, Promise<MultiscaleVolumeChunkSource>>();
export function getShardedVolume(baseUrls: string[], key: string) {
  let cacheKey = stableStringify({'baseUrls': baseUrls, 'key': key});
  let existingResult = existingVolumes.get(key);
  if (existingResult !== undefined) {
    return existingResult;
  }
  let promise =
      sendHttpRequest(openShardedHttpRequest(baseUrls, `/neuroglancer/info/${key}`), 'json')
          .then(response => new MultiscaleVolumeChunkSource(baseUrls, key, response));
  existingVolumes.set(cacheKey, promise);
  return promise;
}

const urlPattern = /^((?:http|https):\/\/[^\/?]+)\/(.*)$/;

export function getVolume(path: string) {
  let match = path.match(urlPattern);
  if (match === null) {
    throw new Error(`Invalid python volume path: ${JSON.stringify(path)}`);
  }
  return getShardedVolume([match[1]], match[2]);
}

registerDataSourceFactory('python', {
  description: 'Python-served volume',
  getVolume: getVolume,
});
Ejemplo n.º 4
0
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Convenience interface for accessing openconnecto.me server.
 */

import {ChunkManager} from 'neuroglancer/chunk_manager/frontend';
import {registerDataSourceFactory} from 'neuroglancer/datasource/factory';
import {getShardedVolume, tokenAndChannelCompleter} from 'neuroglancer/datasource/ndstore/frontend';
import {LEGACY_URL_PREFIX} from 'neuroglancer/datasource/ndstore/base';

const HOSTNAMES = ['http://openconnecto.me', 'http://www.openconnecto.me'];

export function getVolume(chunkManager: ChunkManager, path: string) {
  return getShardedVolume(chunkManager, HOSTNAMES, path, LEGACY_URL_PREFIX);
}

export function volumeCompleter(url: string, chunkManager: ChunkManager) {
  return tokenAndChannelCompleter(chunkManager, HOSTNAMES, url, LEGACY_URL_PREFIX);
}

registerDataSourceFactory('openconnectome', {
  description: 'NDstore server hosted at openconnecto.me',
  getVolume,
  volumeCompleter,
});
Ejemplo n.º 5
0
        completions =
            getPrefixMatchesWithDescriptions(channelMatch[2], channelNames, x => x, x => {
              let channelObject = channelsObject[x];
              return `${channelObject['channel_type']} (${channelObject['datatype']})`;

            });
      }
    }
    return {offset: channelMatch[1].length + 1, completions};
  });
}

export function volumeCompleter(url: string): CancellablePromise<CompletionResult> {
  let match = url.match(urlPattern);
  if (match === null) {
    // We don't yet have a full hostname.
    return Promise.reject<CompletionResult>(null);
  }
  let hostnames = [match[1]];
  let path = match[2];
  return cancellableThen(
      tokenAndChannelCompleter(hostnames, path),
      completions => applyCompletionOffset(match[1].length + 1, completions));
}

registerDataSourceFactory('ndstore', {
  description: 'NDstore',
  volumeCompleter: volumeCompleter,
  getVolume: getVolume,
});
Ejemplo n.º 6
0
    if (projectInfo === undefined) {
      return Promise.reject<CompletionResult>(null);
    }
    let completions =
        getPrefixMatchesWithDescriptions(stackMatch[3], projectInfo.stacks, x => x[0], x => {
          return `${x[1].project}`;
        });
    return {offset: stackMatch[1].length + stackMatch[2].length + 2, completions};
  });
}

export function volumeCompleter(
    url: string, chunkManager: ChunkManager): Promise<CompletionResult> {
  let match = url.match(urlPattern);
  if (match === null) {
    // We don't yet have a full hostname.
    return Promise.reject<CompletionResult>(null);
  }
  let hostnames: string[] = match[1].split(',');
  let path = match[2];

  return stackAndProjectCompleter(chunkManager, hostnames, path)
      .then(completions => applyCompletionOffset(match![1].length + 1, completions));
}

registerDataSourceFactory('render', {
  description: 'Render',
  volumeCompleter: volumeCompleter,
  getVolume: getVolume,
});